Skip to content

Commit 363075a

Browse files
VIA-598 Allow deploy standalone job to run from main
1 parent b92d70c commit 363075a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
description: 'Environment to deploy to'
88
type: environment
99
required: true
10+
version-to-deploy:
11+
description: 'Version tag to deploy (e.g. v1.0.0)'
12+
type: string
13+
required: true
1014
release:
1115
description: 'Run assurance tests based on Hub URL for'
1216
type: choice
@@ -32,14 +36,16 @@ jobs:
3236
version: ${{ steps.variables.outputs.version }}
3337
tag: ${{ steps.variables.outputs.tag }}
3438
steps:
35-
- name: "Check ref"
39+
- name: "Checkout code"
40+
uses: actions/checkout@v5
41+
- name: "Check version exists"
42+
shell: bash
3643
run: |
37-
if ${{ !startsWith(github.ref, 'refs/tags/') }}; then
38-
echo "❌ Only tagged deployments allowed."
44+
RELEASE_VERSION=$(git tag | grep -oP "^${{inputs.version-to-deploy}}$")
45+
if [[ -z "$RELEASE_VERSION" ]]; then
46+
echo "Invalid version number ${{inputs.version-to-deploy}} does not exist."
3947
exit 1
4048
fi
41-
- name: "Checkout code"
42-
uses: actions/checkout@v5
4349
- name: "Set CI/CD variables"
4450
id: variables
4551
run: |
@@ -52,7 +58,7 @@ jobs:
5258
echo "terraform_version=$(grep "^terraform" .tool-versions | cut -f2 -d' ')" | tee -a $GITHUB_OUTPUT
5359
# TODO: Get the version, but it may not be the .version file as this should come from the CI/CD Pull Request Workflow
5460
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
61+
echo "tag=${{ inputs.version-to-deploy }}" | tee -a $GITHUB_OUTPUT
5662
- name: "List variables"
5763
run: |
5864
export BUILD_DATETIME="${{ steps.variables.outputs.build_datetime }}"

0 commit comments

Comments
 (0)