This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
Deploy branch main to test (SHA:a700bda235d57d77c544e52db54ac6aa70ab616c) #279
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: push to AWS | |
run-name: Deploy branch ${{ github.ref_name }} to ${{ inputs.environment || 'test' }} (${{ format('SHA:{0}', github.sha) }}) | |
concurrency: deploy-${{ inputs.environment || 'test' }} | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: Which AWS Account to use | |
type: choice | |
required: true | |
options: | |
- test | |
- production | |
- dev | |
jobs: | |
tag_version: | |
runs-on: ubuntu-latest | |
outputs: | |
version_to_tag: ${{ steps.tagging.outputs.tag_value }} | |
steps: | |
- id: tagging | |
run: | | |
echo "tag_value=$(echo '${{ github.ref }}' | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_OUTPUT | |
paketo_build: | |
permissions: | |
packages: write | |
needs: [ tag_version ] | |
uses: communitiesuk/funding-service-design-workflows/.github/workflows/package.yml@main | |
with: | |
assets_required: true | |
version_to_build: ${{ needs.tag_version.outputs.version_to_tag }} | |
owner: ${{ github.repository_owner }} | |
application: funding-service-design-post-award-submit | |
deployment: | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
needs: [ tag_version, paketo_build ] | |
runs-on: ubuntu-latest | |
environment: ${{ inputs.environment || 'test' }} | |
steps: | |
- name: Git clone the repository | |
uses: actions/checkout@v3 | |
- name: Get current date | |
id: currentdatetime | |
run: echo "::set-output name=datetime::$(date +'%Y%m%d%H%M%S')" | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_NUMBER }}:role/GithubCopilotDeploy | |
role-session-name: POST_AWARD_SUBMIT_${{ steps.currentdatetime.outputs.datetime }} | |
aws-region: eu-west-2 | |
- name: Install AWS Copilot CLI | |
run: | | |
curl -Lo aws-copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x aws-copilot && sudo mv aws-copilot /usr/local/bin/copilot | |
- name: Inject env specific values into manifest | |
run: | | |
yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/submit/manifest.yml | |
yq -i '.image.location = "ghcr.io/communitiesuk/${{ github.event.repository.name }}:${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }}"' copilot/submit/manifest.yml | |
- name: Copilot deploy | |
run: | | |
copilot svc deploy |