Skip to content

Deploy Application - dev #87

Deploy Application - dev

Deploy Application - dev #87

Workflow file for this run

name: Deploy Application - dev
on:
workflow_dispatch:
inputs:
refType:
type: choice
description: "Find branch name, commit SHA, or tag?"
options:
- Branch name
- Commit SHA
- Tag
default: Branch name
gitRef:
description: "Input branch name, commit SHA, or tag"
required: true
type: string
default: main
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
publish-integration-tests-image:
runs-on: ubuntu-latest
permissions:
id-token: write
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
- name: Assume AWS role
uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885
with:
role-to-assume: ${{ secrets.DEV_PIPELINE_GH_ACTIONS_ROLE_ARN }}
aws-region: "eu-west-2"
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@fa648b43de3d4d023bcb3f89ed6940096949c419
- name: Build & publish Docker image
working-directory: solutions/integration-tests
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.DEV_POST_DEPLOY_TESTS_IMAGE_REPOSITORY }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push -a $ECR_REGISTRY/$ECR_REPOSITORY
deploy-to-dev:
needs: publish-integration-tests-image
runs-on: ubuntu-latest
permissions:
id-token: write
packages: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
ref: ${{ inputs.gitRef }}
- name: Set commit SHA
if: github.event.inputs.refType == 'Commit SHA'
run: echo GIT_REF_SHA=${GIT_REF} >> $GITHUB_ENV
env:
GIT_REF: ${{ inputs.gitRef }}
- name: Set commit SHA by branch name
if: github.event.inputs.refType == 'Branch name'
run: echo GIT_REF_SHA=$(git log -1 ${GIT_REF} --pretty=format:%H) >> $GITHUB_ENV
env:
GIT_REF: ${{ inputs.gitRef }}
- name: Set commit SHA by tag
if: github.event.inputs.refType == 'Tag'
run: echo GIT_REF_SHA=$(git rev-list -n 1 ${GIT_REF}) >> $GITHUB_ENV
env:
GIT_REF: ${{ inputs.gitRef }}
- name: Set tag
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Set current datetime
run: echo "date=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version-file: .nvmrc
- name: Set up SAM CLI
uses: aws-actions/setup-sam@89ddb14d60e682855e3fea4be85b3c56485de310
with:
use-installer: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Assume AWS role
uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885
with:
role-to-assume: ${{ secrets.DEV_PIPELINE_GH_ACTIONS_ROLE_ARN }}
aws-region: "eu-west-2"
- name: Install dependencies
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run install-all
- name: Build
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run build:all
- name: Deploy
uses: govuk-one-login/devplatform-upload-action@5879c30205266ad61e8299a4fcea76364530c9c1
with:
artifact-bucket-name: ${{ secrets.DEV_PIPELINE_SOURCE_BUCKET_NAME }}
signing-profile-name: ${{ secrets.DEV_SIGNING_PROFILE_NAME }}
working-directory: ./solutions/app-infra
template-file: .aws-sam/build/template.yaml