-
Notifications
You must be signed in to change notification settings - Fork 2
101 lines (85 loc) · 3.01 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Build
on: [push, pull_request, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: '10'
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Build frontend
run: |
npm install
npx gulp buildAll
- name: Build backend and test
run: |
chmod +x gradlew
./gradlew test bootJar
- name: Detached run test app
run: |
./gradlew bootRun &
# Wait up to 30s for the app to start
- name: Wait for test app start
run: |
export START_TIME=$(date +%s)
until curl http://localhost:8080/health > /dev/null || test "$(($(date +%s) - $START_TIME))" -gt 30; do sleep 5 | echo "Waiting..."; done
shell: bash
- name: Run OpenAPI tests
run: |
pip install schemathesis
schemathesis run --hypothesis-phases=explicit http://localhost:8080/api/v1/energy-labels-openapi.json
- name: Install cf client
env:
CF_CLI_VERSION: v6
run: |
mkdir -p $GITHUB_WORKSPACE/bin
curl -L "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=${CF_CLI_VERSION}" | tar -zx -C $GITHUB_WORKSPACE/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Deploy dev
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
env:
CF_USERNAME: ${{ secrets.CF_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
run: |
cf api api.london.cloud.service.gov.uk
cf auth
cf target -o beis-energy-label-service -s energy-label-service-dev
cf push -f manifest-dev.yml
cf logout
- name: Deploy QA
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/qa' }}
env:
CF_USERNAME: ${{ secrets.CF_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
run: |
cf api api.london.cloud.service.gov.uk
cf auth
cf target -o beis-energy-label-service -s energy-label-service-qa
cf push -f manifest-qa.yml
cf logout
- name: Deploy prod
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
env:
API: api.london.cloud.service.gov.uk
APP: energy-label-service-prod
ORG: beis-energy-label-service
SPACE: energy-label-service-prod
MANIFEST: manifest-prod.yml
SMOKE_TEST: ci/smoke-test.sh
DELETE_OLD_APPS: true
USER: ${{ secrets.CF_USERNAME }}
CF_PASS: ${{ secrets.CF_PASSWORD }}
run: |
chmod +x ci/blue-green-deploy.sh
chmod +x ci/smoke-test.sh
ci/blue-green-deploy.sh