Skip to content

Commit eabacbf

Browse files
authored
Merge pull request #338 from NHSDigital/feature/te-auto-test-deployments
(ELI-444) changed the trigger type to workflow call
2 parents 44c9463 + 7ffa206 commit eabacbf

File tree

2 files changed

+17
-35
lines changed

2 files changed

+17
-35
lines changed

.github/workflows/cicd-2-publish.yaml

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ jobs:
103103
TF_VAR_SPLUNK_HEC_TOKEN: ${{ secrets.SPLUNK_HEC_TOKEN }}
104104
TF_VAR_SPLUNK_HEC_ENDPOINT: ${{ secrets.SPLUNK_HEC_ENDPOINT }}
105105

106-
# just planning for now for safety and until review
107106
run: |
108107
mkdir -p ./build
109108
echo "Running: make terraform env=$ENVIRONMENT workspace=$WORKSPACE stack=networking tf-command=apply"
@@ -119,29 +118,6 @@ jobs:
119118
git tag ${{ needs.metadata.outputs.version }}
120119
git push origin ${{ needs.metadata.outputs.version }}
121120
122-
# --- Keeping these just in case: Uncomment to release to GitHub ---
123-
# - name: "Create release"
124-
# id: create_release
125-
# uses: actions/create-release@v1
126-
# env:
127-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128-
# with:
129-
# tag_name: ${{ needs.metadata.outputs.version }}
130-
# release_name: Release ${{ needs.metadata.outputs.version }}
131-
# body: |
132-
# Release of ${{ needs.metadata.outputs.version }}
133-
# draft: false
134-
# prerelease: true
135-
136-
# - name: "Upload release asset"
137-
# uses: actions/upload-release-asset@v1
138-
# env:
139-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140-
# with:
141-
# upload_url: "${{ steps.create_release.outputs.upload_url }}"
142-
# asset_path: ./build/lambda.zip
143-
# asset_name: lambda-${{ needs.metadata.outputs.version }}.zip
144-
# asset_content_type: application/zip
145121
- name: "Notify Slack on PR merge"
146122
uses: slackapi/[email protected]
147123
with:
@@ -153,3 +129,12 @@ jobs:
153129
Author: "${{ github.actor }}"
154130
title: "Pushed to main"
155131
version: "${{ needs.metadata.outputs.version }}"
132+
133+
call-deploy-test:
134+
name: "Trigger TEST deploy (only on success)"
135+
needs: publish
136+
if: ${{ needs.publish.result == 'success' && github.ref == 'refs/heads/main' }}
137+
uses: .github/workflows/cicd-3-test_auto.yaml
138+
with:
139+
ref: ${{ github.sha }}
140+
secrets: inherit

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: "Auto Deploy to test"
22

33
on:
4-
workflow_run:
5-
workflows: ["CI/CD publish"]
6-
types: [completed]
4+
workflow_call:
5+
inputs:
6+
ref:
7+
required: true
8+
type: string
79

810
concurrency:
911
group: terraform-deploy-test
@@ -18,19 +20,14 @@ jobs:
1820
metadata:
1921
name: "Resolve metadata from triggering run"
2022
runs-on: ubuntu-latest
21-
if: >
22-
${{
23-
github.event.workflow_run.conclusion == 'success' &&
24-
github.event.workflow_run.head_branch == 'main'
25-
}}
2623
outputs:
2724
terraform_version: ${{ steps.vars.outputs.terraform_version }}
2825
tag: ${{ steps.tag.outputs.name }}
2926
steps:
3027
- name: "Checkout exact commit from CI/CD publish"
3128
uses: actions/checkout@v5
3229
with:
33-
ref: ${{ github.event.workflow_run.head_sha }}
30+
ref: ${{ inputs.ref }}
3431

3532
- name: "Set CI/CD variables"
3633
id: vars
@@ -41,7 +38,7 @@ jobs:
4138
id: tag
4239
run: |
4340
git fetch --tags --force
44-
SHA="${{ github.event.workflow_run.head_sha }}"
41+
SHA="${{ inputs.ref }}"
4542
TAG=$(git tag --points-at "$SHA" | grep '^dev-' | head -n1 || true)
4643
if [ -z "$TAG" ]; then
4744
echo "No dev-* tag found on $SHA" >&2
@@ -62,7 +59,7 @@ jobs:
6259
- name: "Checkout same commit"
6360
uses: actions/checkout@v5
6461
with:
65-
ref: ${{ github.event.workflow_run.head_sha }}
62+
ref: ${{ inputs.ref }}
6663

6764
- name: "Setup Terraform"
6865
uses: hashicorp/setup-terraform@v3

0 commit comments

Comments
 (0)