Skip to content

Deploy demo [ATO-1239/upload-to-pact-broker] #3127

Deploy demo [ATO-1239/upload-to-pact-broker]

Deploy demo [ATO-1239/upload-to-pact-broker] #3127

Workflow file for this run

name: Deploy branch
run-name: Deploy demo [${{ github.head_ref || github.ref_name }}]
on:
pull_request:
branches:
- main
types:
- opened
- reopened
- ready_for_review
- synchronize
concurrency: deploy-demo-${{ github.head_ref || github.ref_name }}
permissions:
id-token: write
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(needs.get-head-commit.outputs.commit-message, '[deploy]') == true
name: Push frontend image
needs: get-head-commit
runs-on: ubuntu-latest
environment:
name: demo
url: ${{ steps.push-image.outputs.image-url }}
outputs:
image-uri: ${{ steps.push-image.outputs.image-uri }}
steps:
- name: Login to GDS Dev Dynatrace Container Registry
uses: docker/login-action@v3
with:
registry: khw46367.live.dynatrace.com
username: khw46367
password: ${{ secrets.DYNATRACE_PAAS_TOKEN }}
- name: Push Docker image
uses: govuk-one-login/github-actions/aws/ecr/build-docker-image@7d56b09b4d2a9a9c6005843d28f31a2333ad1373 # 13/03/2024
id: push-image
with:
image-version: ${{ github.sha }}
aws-role-arn: ${{ vars.DEPLOYMENT_ROLE_ARN }}
repository: ${{ vars.FRONTEND_CONTAINER_REPOSITORY_NAME }}
image-tags: "${{ github.head_ref || github.ref_name }}"
dockerfile: infrastructure/frontend/Dockerfile
deploy-frontend:
if: contains(needs.get-head-commit.outputs.commit-message, '[deploy]') == true
name: Deploy frontend (demo)
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 }}
stack-url: ${{ steps.deploy.outputs.stack-url }}
deployment-url: ${{ steps.get-deployment-url.outputs.url }}
environment:
name: demo
url: ${{ steps.get-deployment-url.outputs.url || steps.deploy.outputs.stack-url }}
steps:
- name: Pull repository
id: checkout
uses: actions/checkout@v4
- name: Get deployment name
id: get-deployment-name
uses: govuk-one-login/github-actions/beautify-branch-name@7d56b09b4d2a9a9c6005843d28f31a2333ad1373 # 13/03/2024
with:
length-limit: 22
prefix: preview
verbose: false
- name: Build
id: build
env:
TEMPLATE_FILE: infrastructure/frontend/frontend.template.yml
IMAGE_URI: ${{ needs.push-frontend-image.outputs.image-uri }}
run: |
sam build --cached \
${TEMPLATE_FILE:+--template $TEMPLATE_FILE}
echo "template=.aws-sam/build/template.yaml" >> "$GITHUB_OUTPUT"
if grep -q "CONTAINER-IMAGE-PLACEHOLDER" .aws-sam/build/template.yaml; then
echo "Replacing \"CONTAINER-IMAGE-PLACEHOLDER\" with new ECR image ref"
sed -i "s|CONTAINER-IMAGE-PLACEHOLDER|$IMAGE_URI|" .aws-sam/build/template.yaml
else
echo "WARNING!!! Image placeholder text \"CONTAINER-IMAGE-PLACEHOLDER\" not found - uploading template anyway"
fi
- name: Deploy
uses: govuk-one-login/github-actions/sam/deploy-stack@db4b3614f5f863f56a5356052262878ecec83b31 # 22/07/2024
id: deploy
with:
aws-role-arn: ${{ vars.DEPLOYMENT_ROLE_ARN }}
sam-deployment-bucket: ${{ vars.DEPLOYMENT_ARTIFACTS_BUCKET }}
delete-failed-stack: true
disable-rollback: false
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
sse:application=self-service
sse:deployment-source=github-actions
sse:lifecycle=temporary
parameters: |-
DeploymentName=${{ steps.get-deployment-name.outputs.pretty-branch-name }}
- name: Get deployment URL
id: get-deployment-url
env:
NAME: AdminToolURL
OUTPUTS: ${{ steps.deploy.outputs.stack-outputs }}
run: |
url=$(jq --raw-output ".$NAME" <<< "$OUTPUTS")
printf "🌐 Deployment URL\n%s" "$url" >> "$GITHUB_STEP_SUMMARY"
echo "url=$url" >> "$GITHUB_OUTPUT"
deploy-dynamodb:
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
url: ${{ steps.deploy.outputs.stack-url }}
outputs:
stack-name: ${{ steps.deploy.outputs.stack-name }}
stack-url: ${{ steps.deploy.outputs.stack-url }}
cache-key: ${{ steps.build.outputs.cache-key }}
steps:
- name: Get deployment name
uses: govuk-one-login/github-actions/beautify-branch-name@db4b3614f5f863f56a5356052262878ecec83b31 # 22/07/2024
id: get-deployment-name
with:
length-limit: 22
prefix: preview
verbose: false
- name: Build
id: build
uses: govuk-one-login/github-actions/sam/build-application@6144f39407b01c9b25b39537b3956deca9e32620 # 22/02/2024
with:
template: backend/dynamodb/dynamodb.template.yml
base-dir: backend/dynamodb
source-dir: backend/dynamodb
cache-name: backend-dynamodb-infra
artifact-name: backend-dynamodb-infrastructure
pull-repository: true
- name: Deploy
uses: govuk-one-login/github-actions/sam/deploy-stack@db4b3614f5f863f56a5356052262878ecec83b31 # 22/07/2024
id: deploy
with:
aws-role-arn: ${{ vars.DEPLOYMENT_ROLE_ARN }}
sam-deployment-bucket: ${{ vars.DEPLOYMENT_ARTIFACTS_BUCKET }}
delete-failed-stack: true
disable-rollback: false
stack-name-prefix: preview-dynamodb
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
sse:stack-name=preview-dynamodb
sse:application=self-service
sse:deployment-source=github-actions
parameters: |-
DeploymentName=${{ steps.get-deployment-name.outputs.pretty-branch-name }}
deploy-cognito:
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
url: ${{ steps.deploy.outputs.stack-url }}
outputs:
stack-name: ${{ steps.deploy.outputs.stack-name }}
stack-url: ${{ steps.deploy.outputs.stack-url }}
cache-key: ${{ steps.build.outputs.cache-key }}
steps:
- name: Get deployment name
uses: govuk-one-login/github-actions/beautify-branch-name@db4b3614f5f863f56a5356052262878ecec83b31 # 22/07/2024
id: get-deployment-name
with:
length-limit: 22
prefix: preview
verbose: false
- name: Build
id: build
uses: govuk-one-login/github-actions/sam/build-application@6144f39407b01c9b25b39537b3956deca9e32620 # 22/02/2024
with:
template: backend/cognito/cognito.template.yml
manifest: backend/cognito/package.json
base-dir: backend/cognito
source-dir: backend/cognito
cache-name: backend-cognito-infra
artifact-name: backend-cognito-infrastructure
pull-repository: true
- name: Deploy stack
uses: govuk-one-login/github-actions/sam/deploy-stack@db4b3614f5f863f56a5356052262878ecec83b31 # 22/07/2024
id: deploy
with:
aws-role-arn: ${{ vars.DEPLOYMENT_ROLE_ARN }}
sam-deployment-bucket: ${{ vars.DEPLOYMENT_ARTIFACTS_BUCKET }}
delete-failed-stack: true
disable-rollback: false
stack-name-prefix: preview-cognito
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
sse:stack-name=preview-cognito
sse:application=self-service
sse:deployment-source=github-actions
parameters: |-
DeploymentName=${{ steps.get-deployment-name.outputs.pretty-branch-name }}
deploy-api:
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
url: ${{ steps.deploy.outputs.stack-url }}
outputs:
stack-name: ${{ steps.deploy.outputs.stack-name }}
stack-url: ${{ steps.deploy.outputs.stack-url }}
cache-key: ${{ steps.build.outputs.cache-key }}
steps:
- name: Get deployment name
uses: govuk-one-login/github-actions/beautify-branch-name@db4b3614f5f863f56a5356052262878ecec83b31 # 22/07/2024
id: get-deployment-name
with:
length-limit: 22
prefix: preview
verbose: false
- name: Build
id: build
uses: govuk-one-login/github-actions/sam/build-application@6144f39407b01c9b25b39537b3956deca9e32620 # 22/02/2024
with:
template: backend/api/api.template.yml
manifest: backend/api/package.json
base-dir: backend/api
source-dir: backend/api
additional-artifact-paths: backend/api/state-machines
cache-name: backend-api-infra
artifact-name: backend-api-infrastructure
pull-repository: true
- name: Deploy stack
uses: govuk-one-login/github-actions/sam/deploy-stack@db4b3614f5f863f56a5356052262878ecec83b31 # 22/07/2024
id: deploy
with:
aws-role-arn: ${{ vars.DEPLOYMENT_ROLE_ARN }}
sam-deployment-bucket: ${{ vars.DEPLOYMENT_ARTIFACTS_BUCKET }}
delete-failed-stack: true
disable-rollback: false
stack-name-prefix: preview-api
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
sse:stack-name=preview-api
sse:application=self-service
sse:deployment-source=github-actions
parameters: |-
DeploymentName=${{ steps.get-deployment-name.outputs.pretty-branch-name }}