61
61
prepare-deployment :
62
62
name : Prepare deployment
63
63
runs-on : ubuntu-latest
64
- environment : ${{ inputs.environment }}
65
64
permissions :
66
65
id-token : write
67
66
steps :
@@ -72,37 +71,27 @@ jobs:
72
71
with :
73
72
role-to-assume : ${{ env.aws-role }}
74
73
aws-region : eu-west-2
75
- - name : Get image digest from ECR
76
- id : get-image-digest
77
- run : |
78
- # Get AWS account ID and construct repository URI
79
- AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
80
- REPOSITORY_URI="${AWS_ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/mavis/webapp"
81
-
82
- # Get the image digest for the git SHA
83
- IMAGE_DIGEST=$(aws ecr describe-images \
84
- --repository-name mavis/webapp \
85
- --image-ids imageTag=${{ inputs.git_sha_to_deploy || github.sha }} \
86
- --query 'imageDetails[0].imageDigest' \
87
- --output text)
88
-
89
- NEW_IMAGE_URI="${REPOSITORY_URI}@${IMAGE_DIGEST}"
90
- echo "new-image-uri=${NEW_IMAGE_URI}" >> $GITHUB_OUTPUT
91
- echo "New image URI: ${NEW_IMAGE_URI}"
74
+ - name : Setup python
75
+ uses : actions/setup-python@v4
76
+ with :
77
+ python-version : 3.12.3
78
+ cache : pip
79
+ - name : Install Python dependencies
80
+ run : python3 -m pip install -r script/requirements.txt
92
81
- name : Populate web task definition
93
82
if : inputs.server_types == 'web' || inputs.server_types == 'all'
94
83
id : render-web-task-definition
95
84
run : |
96
- ./ script/populate_task_definition.sh ${{ inputs.environment }} web \
97
- -i "${{ steps.get-image-digest.outputs.new-image-uri }}" \
85
+ python3 script/populate_task_definition.py ${{ inputs.environment }} web \
86
+ -i "${{ inputs.git_sha_to_deploy || github.sha }}" \
98
87
-o web-task-definition.json
99
88
cat web-task-definition.json
100
89
- name : Populate good-job task definition
101
90
if : inputs.server_types == 'good-job' || inputs.server_types == 'all'
102
91
id : render-good-job-task-definition
103
92
run : |
104
- ./ script/populate_task_definition.sh ${{ inputs.environment }} good-job \
105
- -i "${{ steps.get-image-digest.outputs.new-image-uri }}" \
93
+ python3 script/populate_task_definition.py ${{ inputs.environment }} good-job \
94
+ -i "${{ inputs.git_sha_to_deploy || github.sha }}" \
106
95
-o good-job-task-definition.json
107
96
cat good-job-task-definition.json
108
97
- name : Make artifact for web task definition
@@ -118,12 +107,19 @@ jobs:
118
107
outputs :
119
108
new-image-uri : ${{ steps.get-image-digest.outputs.new-image-uri }}
120
109
110
+ approve-deployments :
111
+ name : Approve deployments
112
+ runs-on : ubuntu-latest
113
+ needs : prepare-deployment
114
+ environment : ${{ inputs.environment }}
115
+ steps :
116
+ - run : echo "Proceeding with deployment to ${{ inputs.environment }} environment"
117
+
121
118
deploy-web :
122
119
name : Deploy web service
123
120
runs-on : ubuntu-latest
124
121
if : inputs.server_types == 'web' || inputs.server_types == 'all'
125
- needs : prepare-deployment
126
- environment : ${{ inputs.environment }}
122
+ needs : [ prepare-deployment, approve-deployments ]
127
123
permissions :
128
124
id-token : write
129
125
steps :
@@ -167,8 +163,7 @@ jobs:
167
163
name : Deploy good-job service
168
164
runs-on : ubuntu-latest
169
165
if : inputs.server_types == 'good-job' || inputs.server_types == 'all'
170
- needs : prepare-deployment
171
- environment : ${{ inputs.environment }}
166
+ needs : [ prepare-deployment, approve-deployments ]
172
167
permissions :
173
168
id-token : write
174
169
steps :
0 commit comments