11name : " Updated - 3. CD | Deploy to Test"
22
3- # on:
4- # workflow_run:
5- # workflows: ["2. CD | Deploy to Dev"]
6- # types: [completed]
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ ref :
7+ description : " Branch, tag, or commit SHA to check out"
8+ required : true
9+ default : " main"
10+ artifact_tag :
11+ description : " Artifact tag to deploy, for example dev-20260410120000"
12+ required : true
13+ artifact_run_id :
14+ description : " Workflow run ID that produced the lambda artifact"
15+ required : true
716
817concurrency :
918 group : test-deployments
@@ -16,35 +25,27 @@ permissions:
1625
1726jobs :
1827 metadata :
19- name : " Resolve metadata from triggering run "
28+ name : " Resolve metadata"
2029 runs-on : ubuntu-latest
21- if : ${{ github.event.workflow_run.conclusion == 'success' }}
2230 outputs :
2331 terraform_version : ${{ steps.vars.outputs.terraform_version }}
2432 tag : ${{ steps.tag.outputs.name }}
2533 steps :
26- - name : " Checkout exact commit from CI/CD publish "
34+ - name : " Checkout selected ref "
2735 uses : actions/checkout@v6
2836 with :
29- ref : ${{ github.event.workflow_run.head_sha }}
37+ ref : ${{ inputs.ref }}
3038
3139 - name : " Set CI/CD variables"
3240 id : vars
3341 run : |
3442 echo "terraform_version=$(grep '^terraform' .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
3543
36- - name : " Resolve the dev-* tag for this commit "
44+ - name : " Use provided artifact tag"
3745 id : tag
3846 run : |
39- git fetch --tags --force
40- SHA="${{ github.event.workflow_run.head_sha }}"
41- TAG=$(git tag --points-at "$SHA" | grep '^dev-' | sort -r | head -n1 || true)
42- if [ -z "$TAG" ]; then
43- echo "No dev-* tag found on $SHA" >&2
44- exit 1
45- fi
46- echo "name=$TAG" >> $GITHUB_OUTPUT
47- echo "Resolved tag: $TAG"
47+ echo "name=${{ inputs.artifact_tag }}" >> $GITHUB_OUTPUT
48+ echo "Resolved tag: ${{ inputs.artifact_tag }}"
4849
4950 sign-lambda-artifact :
5051 name : " Sign lambda artifact for TEST"
@@ -58,10 +59,10 @@ jobs:
5859 outputs :
5960 bucket_name : ${{ steps.tf_output.outputs.bucket_name }}
6061 steps :
61- - name : " Checkout same commit "
62+ - name : " Checkout selected ref "
6263 uses : actions/checkout@v6
6364 with :
64- ref : ${{ github.event.workflow_run.head_sha }}
65+ ref : ${{ inputs.ref }}
6566
6667 - name : " Setup Terraform"
6768 uses : hashicorp/setup-terraform@v3
@@ -74,12 +75,12 @@ jobs:
7475 role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
7576 aws-region : eu-west-2
7677
77- - name : " Download lambda artefact from dev workflow"
78+ - name : " Download lambda artefact from chosen workflow run "
7879 uses : actions/download-artifact@v7
7980 with :
8081 name : lambda-${{ needs.metadata.outputs.tag }}
8182 path : ./dist
82- run-id : ${{ github.event.workflow_run.id }}
83+ run-id : ${{ inputs.artifact_run_id }}
8384 github-token : ${{ github.token }}
8485
8586 - name : " Terraform Init (TEST api-layer)"
@@ -111,7 +112,7 @@ jobs:
111112 run : |
112113 VERSION_ID=$(aws s3api head-object \
113114 --bucket "${{ steps.tf_output.outputs.bucket_name }}" \
114- --key "unsigned /${{ needs.metadata.outputs.tag }}/lambda.zip" \
115+ --key "artifacts /${{ needs.metadata.outputs.tag }}/lambda.zip" \
115116 --query 'VersionId' \
116117 --output text \
117118 --region eu-west-2)
@@ -178,10 +179,10 @@ jobs:
178179 id-token : write
179180 contents : read
180181 steps :
181- - name : " Checkout same commit "
182+ - name : " Checkout selected ref "
182183 uses : actions/checkout@v6
183184 with :
184- ref : ${{ github.event.workflow_run.head_sha }}
185+ ref : ${{ inputs.ref }}
185186
186187 - name : " Setup Terraform"
187188 uses : hashicorp/setup-terraform@v3
@@ -228,12 +229,6 @@ jobs:
228229 pip install boto3
229230 python scripts/feature_toggle/validate_toggles.py
230231
231- - name : " Upload signed lambda artifact to S3"
232- run : |
233- aws s3 cp ./dist/lambda.zip \
234- s3://${{ needs.sign-lambda-artifact.outputs.bucket_name }}/artifacts/${{ needs.metadata.outputs.tag }}/lambda.zip \
235- --region eu-west-2
236-
237232 regression-tests :
238233 name : " Regression Tests"
239234 needs : deploy
0 commit comments