From 30fa1549b3ddb9586a853d5eece9e47854533fac Mon Sep 17 00:00:00 2001 From: Andrew Hughes-Onslow Date: Thu, 1 Aug 2024 10:49:34 +0100 Subject: [PATCH] ATO-807: [deploy] Updated branch deployment workflow condition. --- .github/workflows/deploy-branch.yml | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-branch.yml b/.github/workflows/deploy-branch.yml index 9dfd7a6f7..b4a1aa63d 100644 --- a/.github/workflows/deploy-branch.yml +++ b/.github/workflows/deploy-branch.yml @@ -18,9 +18,24 @@ permissions: contents: read jobs: + get-head-commit: + name: Get head commit + runs-on: ubuntu-latest + outputs: + commit-message: ${{ steps.get-head-commit.outputs.commit-message }} + steps: + - name: Checkout Commit + uses: actions/checkout@v4 + with: + ref: ${{ env.GITHUB_SHA }} + - name: Get Head Commit Message + id: get-head-commit + run: echo "commit-message=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT" + push-frontend-image: - if: contains(github.event.head_commit.message, '[deploy]') == true + if: contains(needs.get-head-commit.outputs.commit-message, '[deploy]') == true name: Push frontend image + needs: get-head-commit runs-on: ubuntu-latest environment: name: demo @@ -46,9 +61,9 @@ jobs: dockerfile: infrastructure/frontend/Dockerfile deploy-frontend: - if: contains(github.event.head_commit.message, '[deploy]') == true + if: contains(needs.get-head-commit.outputs.commit-message, '[deploy]') == true name: Deploy frontend (demo) - needs: [ push-frontend-image ] + needs: [ get-head-commit, push-frontend-image ] runs-on: ubuntu-latest outputs: stack-name: ${{ steps.deploy.outputs.stack-name }} @@ -118,8 +133,9 @@ jobs: echo "url=$url" >> "$GITHUB_OUTPUT" deploy-dynamodb: - if: contains(github.event.head_commit.message, '[deploy]') == true + if: contains(needs.get-head-commit.outputs.commit-message, '[deploy]') == true name: Deploy dynamodb (demo) + needs: get-head-commit runs-on: ubuntu-latest environment: name: demo @@ -170,8 +186,9 @@ jobs: DeploymentName=${{ steps.get-deployment-name.outputs.pretty-branch-name }} deploy-cognito: - if: contains(github.event.head_commit.message, '[deploy]') == true + if: contains(needs.get-head-commit.outputs.commit-message, '[deploy]') == true name: Deploy cognito (demo) + needs: get-head-commit runs-on: ubuntu-latest environment: name: demo @@ -223,8 +240,9 @@ jobs: DeploymentName=${{ steps.get-deployment-name.outputs.pretty-branch-name }} deploy-api: - if: contains(github.event.head_commit.message, '[deploy]') == true + if: contains(needs.get-head-commit.outputs.commit-message, '[deploy]') == true name: Deploy API (demo) + needs: get-head-commit runs-on: ubuntu-latest environment: name: demo