Skip to content

Commit 42f3f07

Browse files
Fix race condition
- Ensure that deploy_application uses the same git ref and not 'next' which can change between image creation in the deploy.yml file
1 parent 310c8e6 commit 42f3f07

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

.github/workflows/deploy-application.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ on:
4747
(Git ref to deploy, for example, a tag, branch name or commit SHA. Will use workflow ref if not provided.)
4848
required: true
4949
type: string
50+
app_version:
51+
required: true
52+
type: string
5053

51-
permissions: {}
54+
permissions: { }
5255

5356
env:
5457
environment: ${{ inputs.environment }}
@@ -58,15 +61,15 @@ env:
5861
|| 'arn:aws:iam::393416225559:role/GithubDeployECSService' }}
5962
aws_account_id: ${{ inputs.environment == 'production' && '820242920762' || '393416225559' }}
6063
cluster_name: mavis-${{ inputs.environment }}
61-
app_version: ${{ inputs.git_ref_to_deploy == '' && 'unknown' || inputs.git_ref_to_deploy }}
64+
app_version: ${{ github.event_name == 'workflow_call' && inputs.app_version || (inputs.git_ref_to_deploy == '' && 'unknown' || inputs.git_ref_to_deploy) }}
6265

6366
concurrency:
6467
group: deploy-application-${{ inputs.environment }}
6568

6669
jobs:
6770
determine-git-sha:
6871
runs-on: ubuntu-latest
69-
permissions: {}
72+
permissions: { }
7073
outputs:
7174
git-sha: ${{ steps.get-git-sha.outputs.git-sha }}
7275
steps:
@@ -89,7 +92,7 @@ jobs:
8992
prepare-deployment:
9093
name: Prepare deployment
9194
runs-on: ubuntu-latest
92-
needs: [determine-git-sha, build-and-push-image]
95+
needs: [ determine-git-sha, build-and-push-image ]
9396
permissions:
9497
id-token: write
9598
strategy:
@@ -146,7 +149,7 @@ jobs:
146149
deploy-service:
147150
name: Deploy service
148151
runs-on: ubuntu-latest
149-
needs: [prepare-deployment, approve-deployments]
152+
needs: [ prepare-deployment, approve-deployments ]
150153
permissions:
151154
id-token: write
152155
strategy:

.github/workflows/deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ jobs:
146146
uses: ./.github/workflows/deploy-infrastructure.yml
147147
with:
148148
environment: ${{ inputs.environment }}
149-
git_ref_to_deploy: ${{ inputs.git_ref_to_deploy || github.ref_name }}
149+
git_ref_to_deploy: ${{ needs.determine-git-sha.outputs.git-sha }}
150150
deploy-application:
151151
permissions:
152152
id-token: write
@@ -156,4 +156,5 @@ jobs:
156156
with:
157157
environment: ${{ inputs.environment }}
158158
server_types: ${{ inputs.server_types }}
159-
git_ref_to_deploy: ${{ inputs.git_ref_to_deploy || github.ref_name }}
159+
git_ref_to_deploy: ${{ needs.determine-git-sha.outputs.git-sha }}
160+
app_version: ${{ inputs.git_ref_to_deploy == '' && github.ref_name || inputs.git_ref_to_deploy }}

0 commit comments

Comments
 (0)