This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
generated from communitiesuk/funding-service-design-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (128 loc) · 4.84 KB
/
copilot_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
141
name: Deploy to AWS
on:
workflow_dispatch:
inputs:
environment:
description: Which AWS Account to use
type: choice
required: true
options:
- dev
- test
- uat
- production
run_performance_tests:
required: false
default: false
type: boolean
description: Run performance tests
run_e2e_tests:
required: false
default: false
type: boolean
description: Run e2e tests
push:
paths: # Ignore README markdown and only deploy when something in the copilot folder has changed
- 'copilot/**'
- '!**/README.md'
- 'requirements-dev.in'
- 'requirements-dev.txt'
- 'requirements.in'
- 'requirements.txt'
pull_request:
types:
- closed # Further protection - only allow this workflow to run automatically on closed pull requests
jobs:
tag_version:
runs-on: ubuntu-latest
outputs:
version_to_tag: ${{ steps.assessment_tagging.outputs.tag_value }}
steps:
- id: assessment_tagging
run: |
echo "tag_value=$(echo '${{ github.ref }}' | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_OUTPUT
paketo_build:
needs: [ tag_version ]
permissions:
packages: write
uses: communitiesuk/funding-service-design-workflows/.github/workflows/package.yml@main
with:
version_to_build: $(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
owner: ${{ github.repository_owner }}
application: funding-service-design-assessment
assets_required: true
pre_deploy_tests:
secrets:
E2E_PAT: ${{secrets.E2E_PAT}}
uses: communitiesuk/funding-design-service-workflows/.github/workflows/pre-deploy.yml@main
with:
assets_required: true
postgres_unit_testing: false
copilot_environments_workflow_setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.copilot_env_matrix.outputs.env_list }}
steps:
- id: copilot_env_matrix
run: |
if [ "${{ inputs.environment }}" != '' ]; then
echo "env_list=[\"${{ inputs.environment }}\"]" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" == 'refs/heads/main' ]; then
echo "env_list=[\"dev\", \"test\", \"uat\", \"production\"]" >> $GITHUB_OUTPUT
else
echo "env_list=[\"dev\", \"test\"]" >> $GITHUB_OUTPUT
fi
copilot_env_deploy:
concurrency:
group: '${{ github.workflow }} @ ${{ github.ref }}'
cancel-in-progress: false
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
needs: [ tag_version, pre_deploy_tests, paketo_build, copilot_environments_workflow_setup ]
runs-on: ubuntu-latest
continue-on-error: true
strategy:
max-parallel: 1
matrix:
value: ${{ fromJSON(needs.copilot_environments_workflow_setup.outputs.matrix) }}
fail-fast: false
environment: ${{ matrix.value }}
steps:
- name: Git clone the repository
uses: actions/checkout@v4
- name: Get current date
shell: bash
id: currentdatetime
run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/GithubCopilotDeploy
role-session-name: NOTIFICATION_${{ matrix.value }}_COPILOT_${{ steps.currentdatetime.outputs.datetime }}
aws-region: eu-west-2
- name: Install AWS Copilot CLI
shell: bash
run: |
curl -Lo aws-copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x aws-copilot && sudo mv aws-copilot /usr/local/bin/copilot
- name: Inject Git SHA into manifest
run: |
yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/fsd-assessment/manifest.yml
- name: Inject replacement image into manifest
run: |
yq -i '.image.location = "ghcr.io/communitiesuk/funding-service-design-assessment:${{ github.ref_name == 'main' && 'latest' || github.ref_name }}"' copilot/fsd-assessment/manifest.yml
- name: Copilot ${{ matrix.value }} deploy
id: deploy_build
run: |
copilot svc deploy --env ${{ matrix.value }} --app pre-award
post_deploy_tests:
needs: copilot_env_deploy
if: inputs.environment == 'test' || inputs.environment == 'dev' || inputs.environment == ''
secrets:
E2E_PAT: ${{secrets.E2E_PAT}}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main
with:
run_performance_tests: ${{ inputs.run_performance_tests || false }}
run_e2e_tests: ${{ inputs.run_e2e_tests || true }}
app_name: assessment
environment: ${{ inputs.environment == '' && 'test' || inputs.environment }}