-
Notifications
You must be signed in to change notification settings - Fork 16
140 lines (118 loc) · 4.75 KB
/
build_and_deploy.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Build and deploy to AKS cluster
on:
push:
branches: [master]
pull_request:
types: [labeled, opened, reopened, synchronize]
concurrency: deploy-${{ github.ref }}
permissions:
packages: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
docker-image-tag: ${{ steps.build-image.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build and push docker image
id: build-image
uses: DFE-Digital/github-actions/build-docker-image@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
target: web
context: .
deploy_review:
name: Deploy to review environment
concurrency: deploy_review_${{ github.event.pull_request.number }}
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
needs: [build]
environment:
name: review-aks
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: ./.github/actions/deploy-environment
id: deploy
with:
environment: review-aks
docker-image: ${{ needs.build.outputs.docker-image-tag }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
pull-request-number: ${{ github.event.pull_request.number }}
- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Set kubectl
uses: DFE-Digital/github-actions/set-kubectl@master
- name: Seed review app
shell: bash
if: github.event.number != ''
run: |
make ci review-aks get-cluster-credentials
kubectl exec -n srtl-development deployment/claim-additional-payments-for-teaching-review-${{ github.event.pull_request.number }}-worker -- sh -c "DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bin/prepare-database"
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
- name: Post comment to Pull Request ${{ github.event.number }}
if: ${{ github.event_name == 'pull_request' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: aks
message: |
### Deployments
| Journey | URL |
| ------------------- | -------------------------------------------------------------------|
| Additional Payments | <${{ env.APP_URL }}/additional-payments/claim> |
| Student Loans | <${{ env.APP_URL }}/student-loans/claim> |
| Further Education | <${{ env.APP_URL }}/further-education-payments/landing-page> |
| Relocation Payments | <${{ env.APP_URL }}/get-a-teacher-relocation-payment/landing-page> |
| Admin | <${{ env.APP_URL }}/admin> |
deploy_test:
name: Deploy to test environment
concurrency: deploy_test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: [build]
environment:
name: test-aks
url: ${{ steps.deploy.outputs.environment_url }}
outputs:
environment_url: ${{ steps.deploy.outputs.environment_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: ./.github/actions/deploy-environment
id: deploy
with:
environment: test-aks
docker-image: ${{ needs.build.outputs.docker-image-tag }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
- name: Run migrations
shell: bash
run: |
make ci test-aks get-cluster-credentials
kubectl exec -n srtl-test deployment/claim-additional-payments-for-teaching-test-worker -- sh -c "DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bin/prepare-database"
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run smoke tests
shell: bash
run: bundle exec rspec spec/smoke -t smoke:true -b
env:
RAILS_ENV: test
SMOKE_TEST_APP_HOST: ${{ env.APP_URL }}
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
- name: Notify on failure
if: failure()
uses: rtCamp/action-slack-notify@master
env:
SLACK_COLOR: failure
SLACK_TITLE: Failure deploying release to test
SLACK_MESSAGE: Failure deploying release to test - Docker tag ${{ needs.build.outputs.docker-image-tag }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}