-
Notifications
You must be signed in to change notification settings - Fork 18
94 lines (78 loc) · 2.74 KB
/
deploy_aks.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
name: Build and deploy to AKS cluster
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency: deploy-${{ github.ref }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
docker-image-tag: ${{ steps.build-image.outputs.tag }}
matrix-environments: ${{ toJSON(steps.*.outputs.matrix-environment) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Build docs with middleman
run: make build
- name: Build and push docker image
id: build-image
uses: DFE-Digital/github-actions/build-docker-image@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
context: .
- name: Prepare matrix environments review
id: matrix-env-review
if: github.event_name == 'pull_request'
run: echo "matrix-environment=review" >> $GITHUB_OUTPUT
- name: Prepare matrix environments for production
id: matrix-env-main
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
echo "matrix-environment=production" >> $GITHUB_OUTPUT
deploy:
name: Deploy ${{ matrix.environment }}
runs-on: ubuntu-latest
needs: [build]
environment:
name: ${{ matrix.environment }}
url: ${{ steps.get-app-url.outputs.url }}
strategy:
max-parallel: 1
matrix:
environment: ${{ fromJSON(needs.build.outputs.matrix-environments) }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.6.4
terraform_wrapper: false
- uses: DFE-Digital/github-actions/set-arm-environment-variables@master
with:
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
- name: Terraform Apply
run: |
make ci ${{ matrix.environment }} terraform-apply
env:
DOCKER_IMAGE_TAG: ${{ needs.build.outputs.docker-image-tag }}
PR_NUMBER: ${{ github.event.pull_request.number }}
- name: Get application URL
id: get-app-url
run: |
url=$(terraform -chdir=terraform/application output -raw url)
echo "url=${url}" >> $GITHUB_OUTPUT
- 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: Review app deployed to <${{ steps.get-app-url.outputs.url }}>