Skip to content

Commit 015a690

Browse files
VIA-283 AS/AJ Update workflows to remove refs for checkout, let deploy handle ref type logic, update variable names
1 parent 61b8f94 commit 015a690

File tree

6 files changed

+25
-54
lines changed

6 files changed

+25
-54
lines changed

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ jobs:
114114
with:
115115
environment: "dev"
116116
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
117-
tag: "${{ needs.build-stage.outputs.tag }}"
118117
secrets: inherit
119118
acceptance-stage: # Recommended maximum execution time is 10 minutes
120119
name: "Acceptance stage"

.github/workflows/cicd-3-deploy.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ jobs:
2626
version: ${{ steps.variables.outputs.version }}
2727
tag: ${{ steps.variables.outputs.tag }}
2828
steps:
29+
- name: "Check ref"
30+
run: |
31+
if ${{ !startsWith(github.ref, 'refs/tags/') }}; then
32+
echo "❌ Only tagged deployments allowed."
33+
exit 1
34+
fi
2935
- name: "Checkout code"
3036
uses: actions/checkout@v4
31-
with:
32-
ref: ${{ github.ref }}
3337
- name: "Set CI/CD variables"
3438
id: variables
3539
run: |
@@ -61,7 +65,6 @@ jobs:
6165
with:
6266
environment: ${{ github.event.inputs.environment }}
6367
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
64-
tag: "${{ needs.metadata.outputs.tag }}"
6568
secrets: inherit
6669
acceptance-stage:
6770
name: "Acceptance stage"
@@ -70,13 +73,10 @@ jobs:
7073
uses: ./.github/workflows/stage-5-acceptance.yaml
7174
with:
7275
environment: ${{ github.event.inputs.environment}}
73-
tag: ${{ needs.metadata.outputs.tag }}
7476
secrets: inherit
7577
snapshot-test-stage:
7678
name: "Snapshot Test stage"
7779
if: ${{ github.event.inputs.environment == 'preprod' }}
7880
needs: [metadata, acceptance-stage]
7981
uses: ./.github/workflows/stage-7-snapshot-test.yaml
80-
with:
81-
tag: "${{ needs.metadata.outputs.tag }}"
8282
secrets: inherit

.github/workflows/stage-3-build.yaml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ on:
3131
description: "Version of the software, set by the CI/CD pipeline workflow"
3232
required: true
3333
type: string
34-
outputs:
35-
tag:
36-
description: "SHA of the commit"
37-
value: ${{ jobs.build-and-package.outputs.tag }}
3834

3935
env:
4036
AWS_REGION: eu-west-2
@@ -50,16 +46,9 @@ jobs:
5046
permissions:
5147
id-token: write
5248
contents: read
53-
outputs:
54-
tag: ${{ steps.release-version.outputs.release_version }}
5549
steps:
5650
- name: "Checkout code"
5751
uses: actions/checkout@v4
58-
- name: "Get the release version"
59-
id: release-version
60-
run: |
61-
echo "release_version=${{ github.sha }}" >> $GITHUB_OUTPUT
62-
echo "RELEASE_VERSION=${{ github.sha }}" >> $GITHUB_ENV
6352
- name: "Build OpenNext Package"
6453
run: |
6554
npm ci --ignore-scripts
@@ -82,17 +71,17 @@ jobs:
8271
aws-region: ${{ env.AWS_REGION }}
8372
- name: "Upload Packages To S3"
8473
run: | # Prevent overwriting of existing artefacts
85-
aws s3api put-object --bucket "${AWS_S3_ARTEFACTS_BUCKET}" --key "sha/${RELEASE_VERSION}/open-next.zip" --body "open-next.zip" --if-none-match '*' || {
74+
aws s3api put-object --bucket "${AWS_S3_ARTEFACTS_BUCKET}" --key "sha/${{ github.sha }}/open-next.zip" --body "open-next.zip" --if-none-match '*' || {
8675
echo "❌ Uploading open-next.zip to S3 bucket failed!"
8776
exit 1
8877
}
8978
90-
aws s3api put-object --bucket "${AWS_S3_ARTEFACTS_BUCKET}" --key "sha/${RELEASE_VERSION}/lambda.zip" --body "lambda.zip" --if-none-match '*' || {
79+
aws s3api put-object --bucket "${AWS_S3_ARTEFACTS_BUCKET}" --key "sha/${{ github.sha }}/lambda.zip" --body "lambda.zip" --if-none-match '*' || {
9180
echo "❌ Uploading lambda.zip to S3 bucket failed!"
9281
exit 1
9382
}
9483
95-
aws s3api put-object --bucket "${AWS_S3_ARTEFACTS_BUCKET}" --key "sha/${RELEASE_VERSION}/workflow.log" --body "workflow.log" --if-none-match '*' || {
84+
aws s3api put-object --bucket "${AWS_S3_ARTEFACTS_BUCKET}" --key "sha/${{ github.sha }}/workflow.log" --body "workflow.log" --if-none-match '*' || {
9685
echo "❌ Uploading workflow.log to S3 bucket failed!"
9786
exit 1
9887
}

.github/workflows/stage-4-deploy.yaml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@ on:
66
description: "TF version"
77
required: true
88
type: string
9-
tag:
10-
description: "The commit SHA (DEV) or version tag (higher envs) to be deployed"
11-
required: true
12-
type: string
139
environment:
1410
description: "Environment to deploy to"
1511
required: true
1612
type: string
1713

1814
env:
1915
AWS_REGION: eu-west-2
20-
TAG: ${{ inputs.tag }}
2116

2217
jobs:
2318
deploy:
@@ -33,10 +28,16 @@ jobs:
3328
id-token: write
3429
contents: read
3530
steps:
31+
- name: "Tag or SHA"
32+
id: tag-or-sha
33+
run: |
34+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
35+
echo "value=${{ github.ref_name }}" >> $GITHUB_OUTPUT
36+
else
37+
echo "value=${{ github.sha }}" >> $GITHUB_OUTPUT
38+
fi
3639
- name: "Checkout code"
3740
uses: actions/checkout@v4
38-
with:
39-
ref: ${{ env.TAG }}
4041
- name: "Install Terraform"
4142
uses: hashicorp/setup-terraform@v3
4243
with:
@@ -51,23 +52,23 @@ jobs:
5152
if: ${{ inputs.environment == 'dev' }}
5253
run: |
5354
AWS_S3_ARTEFACTS_BUCKET="vita-${{ secrets.AWS_ACCOUNT_ID }}-artefacts-${{ inputs.environment }}"
54-
app_s3_path="s3://${AWS_S3_ARTEFACTS_BUCKET}/sha/${{ env.TAG }}/open-next.zip"
55+
app_s3_path="s3://${AWS_S3_ARTEFACTS_BUCKET}/sha/${{ steps.tag-or-sha.outputs.value }}/open-next.zip"
5556
echo "Artefact path: $app_s3_path"
5657
aws s3 cp "$app_s3_path" .
57-
lambda_s3_path="s3://${AWS_S3_ARTEFACTS_BUCKET}/sha/${{ env.TAG }}/lambda.zip"
58+
lambda_s3_path="s3://${AWS_S3_ARTEFACTS_BUCKET}/sha/${{ steps.tag-or-sha.outputs.value }}/lambda.zip"
5859
echo "Artefact path: $lambda_s3_path"
5960
aws s3 cp "$lambda_s3_path" .
6061
- name: "Download packages from ${{ inputs.environment}} S3 Releases bucket"
6162
if: ${{ inputs.environment == 'preprod' || inputs.environment == 'prod' }}
6263
run: |
6364
AWS_S3_RELEASE_BUCKET="vita-${{ secrets.AWS_ACCOUNT_ID }}-releases-${{ inputs.environment }}"
64-
app_s3_path="s3://${AWS_S3_RELEASE_BUCKET}/tag/${{ env.TAG }}/open-next.zip"
65+
app_s3_path="s3://${AWS_S3_RELEASE_BUCKET}/tag/${{ steps.tag-or-sha.outputs.value }}/open-next.zip"
6566
echo "Artefact path: $app_s3_path"
6667
aws s3 cp "$app_s3_path" .
67-
lambda_s3_path="s3://${AWS_S3_RELEASE_BUCKET}/tag/${{ env.TAG }}/lambda.zip"
68+
lambda_s3_path="s3://${AWS_S3_RELEASE_BUCKET}/tag/${{ steps.tag-or-sha.outputs.value }}/lambda.zip"
6869
echo "Artefact path: $lambda_s3_path"
6970
aws s3 cp "$lambda_s3_path" .
70-
workflow_s3_path="s3://${AWS_S3_RELEASE_BUCKET}/tag/${{ env.TAG }}/workflow.log"
71+
workflow_s3_path="s3://${AWS_S3_RELEASE_BUCKET}/tag/${{ steps.tag-or-sha.outputs.value }}/workflow.log"
7172
echo "Artefact path: $workflow_s3_path"
7273
aws s3 cp "$workflow_s3_path" .
7374
- name: "Unzip OpenNext Package"
@@ -79,7 +80,7 @@ jobs:
7980
- name: "Set the Slack channel id where alarms are sent"
8081
run: echo "TF_VAR_alarms_slack_channel_id=${{ secrets.ALARMS_SLACK_CHANNEL_ID }}" >> $GITHUB_ENV
8182
- name: "Set the app version being deployed"
82-
run: echo "TF_VAR_app_version=${{ env.TAG }}" >> $GITHUB_ENV
83+
run: echo "TF_VAR_app_version=${{ steps.tag-or-sha.outputs.value }}" >> $GITHUB_ENV
8384
- name: "Terraform init"
8485
id: init
8586
run: TF_ENV=${{ inputs.environment }} make terraform-init

.github/workflows/stage-5-acceptance.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ on:
77
description: "Environment to run tests against"
88
required: true
99
type: string
10-
tag:
11-
description: "The commit SHA (DEV) or version tag (higher envs) to be deployed"
12-
required: false
13-
type: string
14-
15-
env:
16-
TAG: ${{ inputs.tag || github.sha }}
1710

1811
jobs:
1912
test-e2e:
@@ -31,8 +24,6 @@ jobs:
3124
steps:
3225
- name: "Checkout code"
3326
uses: actions/checkout@v4
34-
with:
35-
ref: ${{ env.TAG }}
3627
- name: "Install dependencies"
3728
run: |
3829
npm ci --ignore-scripts
@@ -73,8 +64,6 @@ jobs:
7364
steps:
7465
- name: "Checkout code"
7566
uses: actions/checkout@v4
76-
with:
77-
ref: ${{ env.TAG }}
7867
- name: "Install dependencies"
7968
run: |
8069
npm ci --ignore-scripts

.github/workflows/stage-7-snapshot-test.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: "Snapshot Test stage"
22

33
on:
44
workflow_call:
5-
inputs:
6-
tag:
7-
description: "Tag of deployment"
8-
required: true
9-
type: string
105

116
env:
127
AWS_REGION: eu-west-2
@@ -31,8 +26,6 @@ jobs:
3126
steps:
3227
- name: "Checkout code"
3328
uses: actions/checkout@v4
34-
with:
35-
ref: ${{ inputs.tag }}
3629

3730
- name: "Configure AWS credentials for environment"
3831
uses: aws-actions/configure-aws-credentials@v4
@@ -57,10 +50,10 @@ jobs:
5750
run: |
5851
npm run e2e:snapshot
5952
60-
- name: "Upload snapshots to S3 bucket with tag ${{ inputs.tag }}"
53+
- name: "Upload snapshots to S3 bucket with tag ${{ github.ref_name }}"
6154
if: failure()
6255
run: |
63-
aws s3 sync ./e2e/snapshot/snapshot_review/ s3://${{ env.AWS_S3_ARTEFACTS_BUCKET }}/playwright/${{ inputs.tag }}/
56+
aws s3 sync ./e2e/snapshot/snapshot_review/ s3://${{ env.AWS_S3_ARTEFACTS_BUCKET }}/playwright/${{ github.ref_name }}/
6457
6558
- name: "Upload report"
6659
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)