77 description : ' Environment to deploy to'
88 type : environment
99 required : true
10- release :
11- description : ' Run assurance tests based on Hub URL for'
12- type : choice
13- options :
14- - R1
15- - Latest main
1610
1711env :
1812 AWS_REGION : eu-west-2
1913
2014jobs :
21- metadata :
22- name : " Set CI/CD metadata"
23- runs-on : ubuntu-latest
24- timeout-minutes : 1
25- outputs :
26- build_datetime : ${{ steps.variables.outputs.build_datetime }}
27- build_timestamp : ${{ steps.variables.outputs.build_timestamp }}
28- build_epoch : ${{ steps.variables.outputs.build_epoch }}
29- nodejs_version : ${{ steps.variables.outputs.nodejs_version }}
30- python_version : ${{ steps.variables.outputs.python_version }}
31- terraform_version : ${{ steps.variables.outputs.terraform_version }}
32- version : ${{ steps.variables.outputs.version }}
33- tag : ${{ steps.variables.outputs.tag }}
34- steps :
35- - name : " Check ref"
36- run : |
37- if ${{ !startsWith(github.ref, 'refs/tags/') }}; then
38- echo "❌ Only tagged deployments allowed."
39- exit 1
40- fi
41- - name : " Checkout code"
42- uses : actions/checkout@v6
43- - name : " Set CI/CD variables"
44- id : variables
45- run : |
46- datetime=$(date -u +'%Y-%m-%dT%H:%M:%S%z')
47- echo "build_datetime=$datetime" | tee -a $GITHUB_OUTPUT
48- echo "build_timestamp=$(date --date=$datetime -u +'%Y%m%d%H%M%S')" | tee -a $GITHUB_OUTPUT
49- echo "build_epoch=$(date --date=$datetime -u +'%s')" | tee -a $GITHUB_OUTPUT
50- echo "nodejs_version=$(grep "^nodejs" .tool-versions | cut -f2 -d' ')" | tee -a $GITHUB_OUTPUT
51- echo "python_version=$(grep "^nodejs" .tool-versions | cut -f2 -d' ')" | tee -a $GITHUB_OUTPUT
52- echo "terraform_version=$(grep "^terraform" .tool-versions | cut -f2 -d' ')" | tee -a $GITHUB_OUTPUT
53- # TODO: Get the version, but it may not be the .version file as this should come from the CI/CD Pull Request Workflow
54- echo "version=$(head -n 1 .version 2> /dev/null || echo unknown)" | tee -a $GITHUB_OUTPUT
55- echo "tag=${{ github.ref_name }}" | tee -a $GITHUB_OUTPUT
56- - name : " List variables"
57- run : |
58- export BUILD_DATETIME="${{ steps.variables.outputs.build_datetime }}"
59- export BUILD_TIMESTAMP="${{ steps.variables.outputs.build_timestamp }}"
60- export BUILD_EPOCH="${{ steps.variables.outputs.build_epoch }}"
61- export NODEJS_VERSION="${{ steps.variables.outputs.nodejs_version }}"
62- export PYTHON_VERSION="${{ steps.variables.outputs.python_version }}"
63- export TERRAFORM_VERSION="${{ steps.variables.outputs.terraform_version }}"
64- export VERSION="${{ steps.variables.outputs.version }}"
65- export TAG="${{ steps.variables.outputs.tag }}"
66- make list-variables
67- deploy-stage :
68- name : " Deploy ${{ needs.metadata.outputs.tag }} to ${{ github.event.inputs.environment }}"
69- needs : [ metadata ]
15+
16+ # ############################################################
17+ # Deploy action - download artefacts and deploy to AWS
18+ # ############################################################
19+
20+ deploy-action :
21+ name : " Deploy ${{ github.ref_name }} to (${{ github.event.inputs.environment }})"
7022 runs-on : ubuntu-latest
7123 environment :
7224 name : ${{ github.event.inputs.environment }}
@@ -78,30 +30,33 @@ jobs:
7830 id-token : write
7931 contents : read
8032 steps :
81- - name : " Tag or SHA"
82- id : tag-or-sha
33+ - name : " Check is ${{ github.ref }} a tag"
8334 run : |
84- echo "value= ${{ needs.metadata.outputs.tag }}" >> $GITHUB_OUTPUT
85- - name : " Checkout code "
86- uses : actions/checkout@v6
87- with :
88- ref : ${{ needs.metadata.outputs.tag }}
89- - name : " Deploy ${{ needs.metadata.outputs.tag }} to ${{ github.event.inputs.environment }}"
35+ if ${{ !startsWith(github.ref, 'refs/tags/') }}; then
36+ echo "❌ Only tagged deployments allowed. "
37+ exit 1
38+ fi
39+
40+ - name : " Deploy application version ${{ github.ref_name }}"
9041 timeout-minutes : 10
9142 uses : ./.github/actions/deploy
9243 with :
9344 environment : ${{ github.event.inputs.environment }}
94- tag_or_sha_to_deploy : ${{ needs.metadata.outputs.tag }}
45+ tag_or_sha_to_deploy : ${{ github.ref_name }}
9546 secret_aws_iam_role : ${{ secrets.IAM_ROLE }}
9647 secret_aws_account_id : ${{ secrets.AWS_ACCOUNT_ID }}
9748 secret_aws_slack_channel_id : ${{ secrets.ALARMS_SLACK_CHANNEL_ID }}
49+
50+ # ############################################################
51+ # Acceptance stage - E2E and contract tests
52+ # ############################################################
53+
9854 acceptance-stage :
99- name : " Acceptance stage"
55+ name : " Acceptance stage (dev/preprod only) "
10056 if : ${{ contains(fromJSON('["dev","preprod"]'), github.event.inputs.environment) }}
101- needs : [ metadata, deploy-stage ]
57+ needs : [ deploy-action ]
10258 uses : ./.github/workflows/stage-5-acceptance.yaml
10359 with :
10460 environment : ${{ github.event.inputs.environment}}
105- checkout_ref : ${{ needs.metadata.outputs.tag }}
106- release : ${{ inputs.release }}
61+ checkout_ref : ${{ github.ref_name }}
10762 secrets : inherit
0 commit comments