Skip to content

Commit 5d01e92

Browse files
VIA-598 AJ Cleanup and simplify rest of the workflows
1 parent 3389db4 commit 5d01e92

File tree

7 files changed

+65
-213
lines changed

7 files changed

+65
-213
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ jobs:
131131
secrets: inherit
132132

133133
#############################################################
134-
# Deploy stage - download artefacts and deploy to AWS
134+
# Deploy action - download artefacts and deploy to AWS
135135
#############################################################
136136

137-
deploy-stage:
138-
name: "Deploy stage"
137+
deploy-action:
138+
name: "Deploy action (main only)"
139139
needs: [ metadata, build-stage ]
140140
if: github.ref == 'refs/heads/main'
141141
runs-on: ubuntu-latest
@@ -163,12 +163,11 @@ jobs:
163163
#############################################################
164164

165165
acceptance-stage: # Recommended maximum execution time is 10 minutes
166-
name: "Acceptance stage"
167-
needs: [ metadata, deploy-stage ]
166+
name: "Acceptance stage (main only)"
167+
needs: [ metadata, deploy-action ]
168168
if: github.ref == 'refs/heads/main'
169169
uses: ./.github/workflows/stage-5-acceptance.yaml
170170
with:
171171
environment: "dev"
172172
checkout_ref: "${{ github.sha }}"
173-
release: "Latest main tag"
174173
secrets: inherit

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

Lines changed: 23 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -7,66 +7,18 @@ on:
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

1711
env:
1812
AWS_REGION: eu-west-2
1913

2014
jobs:
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

.github/workflows/cicd-4-promote.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ env:
1414
AWS_S3_TARGET_RELEASES_BUCKET: vita-${{ secrets.AWS_ACCOUNT_ID }}-releases-${{ github.event.inputs.environment }}
1515

1616
jobs:
17+
18+
#################################################
19+
# Set up metadata for the jobs
20+
#################################################
21+
1722
metadata:
1823
name: "Set CI/CD metadata"
1924
runs-on: ubuntu-latest
@@ -25,7 +30,7 @@ jobs:
2530
version: ${{ steps.variables.outputs.version }}
2631
release_tag: ${{ steps.variables.outputs.release_tag }}
2732
steps:
28-
- name: "Check ref"
33+
- name: "Check is ${{ github.ref }} a tag"
2934
run: |
3035
if ${{ !startsWith(github.ref, 'refs/tags/') }}; then
3136
echo "❌ Only tagged promotions allowed."
@@ -51,11 +56,15 @@ jobs:
5156
export VERSION="${{ steps.variables.outputs.version }}"
5257
export RELEASE_TAG="${{ steps.variables.outputs.release_tag }}"
5358
make list-variables
59+
60+
#################################################################
61+
# Promote stage - promote builds from one environment to another
62+
#################################################################
63+
5464
promote-stage:
5565
name: "Promote stage"
56-
needs: [ metadata ]
5766
uses: ./.github/workflows/stage-6-promote.yaml
5867
with:
5968
environment: ${{ inputs.environment }}
60-
release_tag: ${{ needs.metadata.outputs.release_tag }}
69+
release_tag: ${{ github.ref_name }}
6170
secrets: inherit

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ env:
3838

3939
jobs:
4040
build-and-package:
41-
name: "Build and package"
41+
name: "Build and upload artefacts"
4242
runs-on: ubuntu-latest
4343
environment:
4444
name: dev

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

Lines changed: 0 additions & 103 deletions
This file was deleted.

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ on:
1616
required: false
1717
type: boolean
1818
default: false
19-
release:
20-
description: "Release name used to infer the URL of the VitA Hub page"
21-
required: true
22-
type: string
19+
20+
env:
21+
AWS_REGION: eu-west-2
2322

2423
jobs:
2524
test-e2e:
26-
name: "E2E Test: ${{inputs.environment}} environment"
25+
name: "E2E Tests on (${{inputs.environment}})"
2726
runs-on: ubuntu-latest
2827
timeout-minutes: 30
2928
environment: ${{ inputs.environment }}
@@ -36,13 +35,14 @@ jobs:
3635
steps:
3736
- name: "Get URL of VitA Hub Page for release"
3837
id: get-hub-url
38+
shell: bash
3939
run: |
40-
if ${{ inputs.release == 'R1' || inputs.release == 'release1' }}; then
40+
if [[ ${{ inputs.checkout_ref }} == v1.0.* }} ]]; then
4141
TEST_APP_URL=${{vars.TEST_APP_URL_R1}}
4242
else
4343
TEST_APP_URL=${{vars.TEST_APP_URL_MAIN}}
4444
fi
45-
echo "test_app_url=$TEST_APP_URL" >> $GITHUB_OUTPUT
45+
echo "test_app_url=$TEST_APP_URL" | tee -a $GITHUB_OUTPUT
4646
4747
- name: "Checkout code"
4848
uses: actions/checkout@v6
@@ -54,9 +54,9 @@ jobs:
5454
with:
5555
role-session-name: GitHubActionsSession
5656
role-to-assume: ${{ secrets.IAM_ROLE }}
57-
aws-region: eu-west-2
57+
aws-region: ${{ env.AWS_REGION }}
5858

59-
- name: "Check expected version is running in ${{inputs.environment}}"
59+
- name: "Check ${{ inputs.checkout_ref }} is running on (${{inputs.environment}})"
6060
timeout-minutes: 20
6161
shell: bash
6262
run: |
@@ -67,7 +67,7 @@ jobs:
6767
exit 1
6868
fi
6969
70-
- name: "Run E2E tests on ${{ inputs.checkout_ref }} (${{ inputs.environment }})"
70+
- name: "Run E2E tests for version - ${{ inputs.checkout_ref }}"
7171
timeout-minutes: 10
7272
uses: ./.github/actions/run-e2e-tests
7373
with:
@@ -85,7 +85,7 @@ jobs:
8585
DEPLOY_ENVIRONMENT: ${{ inputs.environment }}
8686

8787
test-contract:
88-
name: "Contract Test: ${{inputs.environment}} environment"
88+
name: "Contract Tests on (${{inputs.environment}})"
8989
runs-on: ubuntu-latest
9090
timeout-minutes: 5
9191
environment: ${{ inputs.environment }}
@@ -95,7 +95,7 @@ jobs:
9595
with:
9696
ref: ${{ inputs.checkout_ref }}
9797

98-
- name: "Run contract tests (sandpit+mocked)"
98+
- name: "Run contract tests for version - ${{ inputs.checkout_ref }} (EliD:sandpit, EliD:mocked)"
9999
timeout-minutes: 3
100100
uses: ./.github/actions/run-contract-tests
101101
with:

0 commit comments

Comments
 (0)