Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into dependabot-pip-urllib3-1.26.18
Browse files Browse the repository at this point in the history
  • Loading branch information
srh-sloan authored Nov 9, 2023
2 parents c29198f + c023442 commit 3a027e0
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 173 deletions.
59 changes: 0 additions & 59 deletions .github/workflows/copilot.yml

This file was deleted.

140 changes: 140 additions & 0 deletions .github/workflows/copilot_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Deploy to AWS
on:
workflow_dispatch:
inputs:
environment:
description: Which AWS Account to use
type: choice
required: true
options:
- dev
- test
- uat
- production
run_performance_tests:
required: false
default: false
type: boolean
description: Run performance tests
run_e2e_tests:
required: false
default: true
type: boolean
description: Run e2e tests
push:
# Ignore README markdown
# Only automatically deploy when something in the app or tests folder has changed
paths:
- '!**/README.md'
- 'app/**'
- 'tests/**'
- 'requirements-dev.in'
- 'requirements-dev.txt'
- 'requirements.in'
- 'requirements.txt'
- '.github/workflows/copilot_deploy.yml'

jobs:
tag_version:
runs-on: ubuntu-latest
outputs:
version_to_tag: ${{ steps.fund_store_tagging.outputs.tag_value }}
steps:
- id: fund_store_tagging
run: |
echo "tag_value=$(echo '${{ github.ref }}' | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_OUTPUT
paketo_build:
needs: [ tag_version ]
permissions:
packages: write
uses: communitiesuk/funding-service-design-workflows/.github/workflows/package.yml@main
with:
version_to_build: ${{ needs.tag_version.outputs.version_to_tag }}
owner: ${{ github.repository_owner }}
application: funding-service-design-fund-store

pre_deploy_tests:
secrets:
E2E_PAT: ${{secrets.E2E_PAT}}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/pre-deploy.yml@main
with:
# Note - no db-name, so defaults to postgres_db
postgres_unit_testing: true
copilot_environments_workflow_setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.copilot_env_matrix.outputs.env_list }}
steps:
- id: copilot_env_matrix
run: |
if [ "${{ inputs.environment }}" != '' ]; then
echo "env_list=[\"${{ inputs.environment }}\"]" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" == 'refs/heads/main' ]; then
echo "env_list=[\"dev\", \"test\", \"uat\", \"production\"]" >> $GITHUB_OUTPUT
else
echo "env_list=[\"dev\", \"test\"]" >> $GITHUB_OUTPUT
fi
copilot_env_deploy:
concurrency:
group: '${{ github.workflow }} @ ${{ github.ref }}'
cancel-in-progress: false
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
needs: [ tag_version, pre_deploy_tests, paketo_build, copilot_environments_workflow_setup ]
runs-on: ubuntu-latest
continue-on-error: true
strategy:
max-parallel: 1
matrix:
value: ${{ fromJSON(needs.copilot_environments_workflow_setup.outputs.matrix) }}
fail-fast: false
environment: ${{ matrix.value }}
steps:
- name: Git clone the repository
uses: actions/checkout@v4

- name: Get current date
shell: bash
id: currentdatetime
run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/GithubCopilotDeploy
role-session-name: FUND_STORE_${{ matrix.value }}_COPILOT_${{ steps.currentdatetime.outputs.datetime }}
aws-region: eu-west-2

- name: Install AWS Copilot CLI
shell: bash
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 Git SHA into manifest
run: |
yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/fsd-fund-store/manifest.yml
- name: Inject replacement image into manifest
run: |
yq -i '.image.location = "ghcr.io/communitiesuk/funding-service-design-fund-store:${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }}"' copilot/fsd-fund-store/manifest.yml
- name: Copilot ${{ matrix.value }} deploy
id: deploy_build
run: |
copilot svc deploy --env ${{ matrix.value }} --app pre-award
# Can we realistically run E2E at this stage, or just plump for application on the grounds it checks fund-store is operational?
post_deploy_tests:
needs: copilot_env_deploy
if: inputs.environment == 'test' || inputs.environment == 'dev' || inputs.environment == ''
secrets:
E2E_PAT: ${{secrets.E2E_PAT}}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main
with:
run_performance_tests: ${{ inputs.run_performance_tests || false }}
run_e2e_tests: ${{ inputs.run_e2e_tests || true }}
app_name: application
environment: ${{ inputs.environment == '' && 'test' || inputs.environment }}
71 changes: 0 additions & 71 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@ name: Deploy fsd-fund-store to Gov PaaS
on:
workflow_dispatch:
inputs:
environment:
description: Which AWS Account to use
type: choice
required: true
options:
- test
- uat
copilot:
description: Whether to deploy to AWS?
type: boolean
required: false
default: false
deploy_to_dev:
required: false
default: false
Expand All @@ -26,7 +14,6 @@ on:

jobs:
test_and_deploy:
if: ${{github.event.inputs.copilot != 'true'}}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/deploy.yml@main
with:
app_name: ${{ github.event.repository.name }}
Expand All @@ -42,61 +29,3 @@ jobs:
CF_USER: ${{secrets.CF_USERNAME}}
CF_PASSWORD: ${{secrets.CF_PASSWORD}}
E2E_PAT: ${{secrets.E2E_PAT}}
paketo_build:
permissions:
packages: write
uses: communitiesuk/funding-service-design-workflows/.github/workflows/package.yml@main
with:
version_to_build: $(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
owner: ${{ github.repository_owner }}
application: funding-service-design-fund-store
pre_deploy_tests:
if: ${{github.event.inputs.copilot == 'true'}}
secrets:
E2E_PAT: ${{secrets.E2E_PAT}}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/pre-deploy.yml@main
with:
# Note - no db-name, so defaults to postgres_db
postgres_unit_testing: true
copilot_build:
if: ${{github.event.inputs.copilot == 'true'}}
needs: [pre_deploy_tests, paketo_build]
concurrency: deploy-${{ inputs.environment || 'test' }}
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
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 "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/GithubCopilotDeploy
role-session-name: FUNDSTORE_COPILOT_${{ 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 Git SHA into manifest
run: |
yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/fsd-fund-store/manifest.yml
- name: Inject replacement image into manifest
run: |
yq -i '.image.location = "ghcr.io/communitiesuk/funding-service-design-fund-store:${{ github.ref_name == 'main' && 'latest' || github.ref_name }}"' copilot/fsd-fund-store/manifest.yml
- name: Run database migrations
run: scripts/migration-task-script.py ${{ inputs.environment || 'test' }} 'fsd-fund-store'

- name: Copilot deploy
run: |
copilot svc deploy --env ${{ inputs.environment || 'test' }}
4 changes: 2 additions & 2 deletions .github/workflows/manual-dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
FLASK_ENV: dev
steps:
- name: checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -20,7 +20,7 @@
- name: install dependencies
run: source .venv/bin/activate && python -m pip install --upgrade pip && pip install -r requirements.txt
- name: download previous build
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
- name: Deploy to Gov PaaS
uses: citizen-of-planet-earth/cf-cli-action@v2
with:
Expand Down
Loading

0 comments on commit 3a027e0

Please sign in to comment.