-
Notifications
You must be signed in to change notification settings - Fork 2
61 lines (52 loc) · 2.36 KB
/
_deploy-shared.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
name: '(shared functionality) Deploy'
on:
workflow_call:
inputs:
GITHUB_ACTIONS_ENVIRONMENT:
required: true
type: string
EB_APP_NAME:
required: true
type: string
EB_ENVIRONMENT_NAME:
required: true
type: string
EB_CODE_BUCKET:
required: true
type: string
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
env:
AWS_DEFAULT_REGION: eu-west-2
TERRAFORM_STATE_BUCKET: uk-gov-equality-hub-terraform-state-bucket
jobs:
deploy:
name: 'Deploy (${{ inputs.GITHUB_ACTIONS_ENVIRONMENT }})'
runs-on: ubuntu-latest
environment: ${{ inputs.GITHUB_ACTIONS_ENVIRONMENT }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-west-2
ZIP_FILE_NAME: "run${{ github.run_id }}_${{ inputs.GITHUB_ACTIONS_ENVIRONMENT }}_attempt${{ github.run_attempt }}.zip"
EB_VERSION_LABEL: "v_run${{ github.run_id }}_${{ inputs.GITHUB_ACTIONS_ENVIRONMENT }}_attempt${{ github.run_attempt }}"
steps:
- name: 'Download build zip from GitHub Actions artifacts'
uses: actions/download-artifact@v4
with:
name: build-zip
- name: 'Copy the zip file to AWS S3'
run: |
aws s3 cp ./build.zip "s3://${{ inputs.EB_CODE_BUCKET }}/${{ env.ZIP_FILE_NAME }}"
- name: 'Create Elastic Beanstalk application version'
run: |
aws elasticbeanstalk create-application-version --application-name "${{ inputs.EB_APP_NAME }}" --version-label "${{ env.EB_VERSION_LABEL }}" --source-bundle "S3Bucket=${{ inputs.EB_CODE_BUCKET }},S3Key=${{ env.ZIP_FILE_NAME }}"
- name: 'Deploy new version to Elastic Beanstalk instances'
run: |
aws elasticbeanstalk update-environment --application-name "${{ inputs.EB_APP_NAME }}" --environment-name "${{ inputs.EB_ENVIRONMENT_NAME }}" --version-label "${{ env.EB_VERSION_LABEL }}"
- name: 'Wait for the Elastic Beanstalk environment to finish updating (to prevent us trying to deploy two changes at once)'
run: |
aws elasticbeanstalk wait environment-updated --application-name "${{ inputs.EB_APP_NAME }}" --environment-name "${{ inputs.EB_ENVIRONMENT_NAME }}" --version-label "${{ env.EB_VERSION_LABEL }}"