diff --git a/.github/workflows/deploy-branch.yml b/.github/workflows/deploy-branch.yml index 9dfd7a6f7..a8dee8bb9 100644 --- a/.github/workflows/deploy-branch.yml +++ b/.github/workflows/deploy-branch.yml @@ -18,9 +18,28 @@ 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: ${{ github.event.pull_request.head.sha }} + + - name: Get Head Commit Message + id: get-head-commit + run: echo "commit-message=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT" + + - name: Show commit message + run: echo "Git commit message \`$(git show -s --format=%s)\`" >> $GITHUB_STEP_SUMMARY + 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 +65,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, deploy-dynamodb, deploy-cognito, deploy-api ] runs-on: ubuntu-latest outputs: stack-name: ${{ steps.deploy.outputs.stack-name }} @@ -98,6 +117,7 @@ jobs: stack-name-prefix: preview-frontend template: ${{ steps.build.outputs.template }} s3-prefix: sse-preview + pull-repository: false tags: |- sse:component=frontend sse:stack-type=preview @@ -118,8 +138,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 @@ -160,6 +181,7 @@ jobs: template: .aws-sam/build/template.yaml cache-name: ${{ steps.build.outputs.cache-key }} s3-prefix: sse-preview + pull-repository: false tags: |- sse:component=dynamodb sse:stack-type=preview @@ -170,8 +192,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 @@ -213,6 +236,7 @@ jobs: template: .aws-sam/build/template.yaml cache-name: ${{ steps.build.outputs.cache-key }} s3-prefix: sse-preview + pull-repository: false tags: |- sse:component=cognito sse:stack-type=preview @@ -223,8 +247,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 @@ -267,6 +292,7 @@ jobs: template: .aws-sam/build/template.yaml cache-name: ${{ steps.build.outputs.cache-key }} s3-prefix: sse-preview + pull-repository: false tags: |- sse:component=api sse:stack-type=preview