Skip to content

Commit

Permalink
FPASF-461: Simplify deployment workflows & concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcUsher committed Aug 7, 2024
1 parent 169f43a commit 5a75833
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 69 deletions.
37 changes: 17 additions & 20 deletions .github/workflows/aws_copilot_deployment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable workflow for AWS Copilot deployment
name: Reusable workflow for post-award AWS Copilot deployment
run-name: Deploy branch ${{ github.ref_name }} to ${{ inputs.copilot_environment || 'test' }} (${{ format('SHA:{0}', github.sha) }})
on:
workflow_call:
Expand All @@ -7,25 +7,22 @@ on:
description: "Copilot environment to deploy to"
type: string
required: true
github_sha:
description: "Github SHA of the commit being deployed"
type: string
required: true
deployment:
description: "Service or job to be deployed"
type: string
required: true
command:
description: "Command to run for deployment"
type: string
required: true
IMAGE_LOCATION:
image_location:
description: "Location of the image to deploy"
type: string
required: true

jobs:
copilot_deploy:
strategy:
matrix:
include:
- deployment: post-award
command: svc
- deployment: post-award-celery
command: svc
- deployment: download-report
command: job
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
Expand All @@ -43,13 +40,13 @@ jobs:

- name: Inject env specific values into manifest
run: |
yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/${{ inputs.deployment }}/manifest.yml
yq -i '.image.location = "${{ inputs.IMAGE_LOCATION }}"' copilot/${{ inputs.deployment }}/manifest.yml
yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/${{ matrix.deployment }}/manifest.yml
yq -i '.image.location = "${{ inputs.image_location }}"' copilot/${{ matrix.deployment }}/manifest.yml
- name: Run database migrations
if: ${{ inputs.deployment == 'post-award' }}
run: scripts/migration-task-script.py ${{ inputs.copilot_environment || 'test' }} ${{ inputs.IMAGE_LOCATION }}
if: ${{ matrix.deployment == 'post-award' }}
run: scripts/migration-task-script.py ${{ inputs.copilot_environment || 'test' }} ${{ inputs.image_location }}

- name: Copilot deploy ${{ inputs.deployment }}
- name: Copilot deploy ${{ matrix.deployment }}
run: |
copilot ${{ inputs.command }} deploy --name ${{ inputs.deployment }}
copilot ${{ matrix.command }} deploy --name ${{ matrix.deployment }}
22 changes: 4 additions & 18 deletions .github/workflows/deploy_combined_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ on:
options:
- dev
- test
# - prod # This is our production environment and only /main branch can deploy to it

concurrency:
group: deploy-${{ inputs.environment || 'test' }}
cancel-in-progress: false

jobs:
paketo_build:
Expand All @@ -29,20 +24,11 @@ jobs:

copilot_deploy:
needs: [ paketo_build ]
strategy:
matrix:
include:
- deployment: post-award
command: svc
- deployment: post-award-celery
command: svc
- deployment: download-report
command: job
concurrency:
group: deploy-${{ inputs.environment || 'test' }}
cancel-in-progress: false
uses: ./.github/workflows/aws_copilot_deployment.yml
with:
copilot_environment: ${{ inputs.environment || 'test' }}
github_sha: ${{ github.sha }}
deployment: ${{ matrix.deployment }}
command: ${{ matrix.command }}
IMAGE_LOCATION: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
image_location: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
secrets: inherit
40 changes: 9 additions & 31 deletions .github/workflows/deployment_cd_test_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ on:
branches:
- main

concurrency:
group: deploy-test
cancel-in-progress: false

jobs:
paketo_build:
permissions:
Expand All @@ -23,41 +19,23 @@ jobs:

copilot_test_deploy:
needs: [ paketo_build ]
strategy:
matrix:
include:
- deployment: post-award
command: svc
- deployment: post-award-celery
command: svc
- deployment: download-report
command: job
concurrency:
group: deploy-test
cancel-in-progress: false
uses: ./.github/workflows/aws_copilot_deployment.yml
with:
copilot_environment: test
github_sha: ${{ github.sha }}
deployment: ${{ matrix.deployment }}
command: ${{ matrix.command }}
IMAGE_LOCATION: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
image_location: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
secrets: inherit

copilot_prod_deploy:
if: github.ref_name == 'main'
if: ${{ github.ref_name == 'main' }}
needs: [ paketo_build, copilot_test_deploy ]
strategy:
matrix:
include:
- deployment: post-award
command: svc
- deployment: post-award-celery
command: svc
- deployment: download-report
command: job
concurrency:
group: deploy-prod
cancel-in-progress: false
uses: ./.github/workflows/aws_copilot_deployment.yml
with:
copilot_environment: prod
github_sha: ${{ github.sha }}
deployment: ${{ matrix.deployment }}
command: ${{ matrix.command }}
IMAGE_LOCATION: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
image_location: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
secrets: inherit

0 comments on commit 5a75833

Please sign in to comment.