-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1218 from UKHSA-Internal/task/add-workflow-to-dep…
…loy-feature-branches/CDD-2448 Task/add workflow to deploy feature branches/cdd 2448
- Loading branch information
Showing
3 changed files
with
245 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
name: Create Personal Development Environment | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
name: | ||
description: "The name of the dev environment you wish to deploy to e.g. abcd1234" | ||
required: true | ||
type: string | ||
|
||
env: | ||
AWS_REGION: "eu-west-2" | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
terraform_apply: | ||
name: Terraform apply | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
|
||
- name: Configure AWS credentials for tools account | ||
uses: ./.github/actions/configure-aws-credentials | ||
with: | ||
aws-region: ${{ env.AWS_REGION }} | ||
tools-account-role: ${{ secrets.UHD_TERRAFORM_IAM_ROLE }} | ||
role-duration-seconds: "7200" | ||
|
||
- uses: ./.github/actions/setup-terraform | ||
- uses: ./.github/actions/setup-zsh | ||
|
||
- name: Terraform apply | ||
run: | | ||
source uhd.sh | ||
uhd terraform init:layer 20-app | ||
uhd terraform apply:layer 20-app ${{ inputs.name }} | ||
shell: zsh {0} | ||
|
||
push_docker_images: | ||
name: Push docker images | ||
runs-on: ubuntu-latest | ||
needs: ["terraform_apply"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials for tools account | ||
uses: ./.github/actions/configure-aws-credentials | ||
with: | ||
aws-region: ${{ env.AWS_REGION }} | ||
tools-account-role: ${{ secrets.UHD_TERRAFORM_IAM_ROLE }} | ||
|
||
- uses: ./.github/actions/setup-zsh | ||
|
||
- name: Pull / push docker images | ||
run: | | ||
source uhd.sh | ||
uhd docker update dev ${{ inputs.name }} | ||
shell: zsh {0} | ||
|
||
restart_services: | ||
name: Restart services | ||
runs-on: ubuntu-latest | ||
needs: ["push_docker_images"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials for tools account | ||
uses: ./.github/actions/configure-aws-credentials | ||
with: | ||
aws-region: ${{ env.AWS_REGION }} | ||
tools-account-role: ${{ secrets.UHD_TERRAFORM_IAM_ROLE }} | ||
|
||
- uses: ./.github/actions/setup-terraform | ||
- uses: ./.github/actions/setup-zsh | ||
|
||
- name: Terraform output | ||
run: | | ||
source uhd.sh | ||
uhd terraform init:layer 20-app | ||
uhd terraform output:layer 20-app ${{ inputs.name }} | ||
shell: zsh {0} | ||
|
||
- name: Configure AWS credentials for dev account | ||
uses: ./.github/actions/configure-aws-credentials | ||
with: | ||
account-name: "dev" | ||
aws-region: ${{ env.AWS_REGION }} | ||
dev-account-role: ${{ secrets.UHD_TERRAFORM_ROLE_DEV }} | ||
|
||
- name: Restart ECS services | ||
run: | | ||
source uhd.sh | ||
uhd ecs restart-services | ||
shell: zsh {0} | ||
|
||
- name: Redeploy lambda functions | ||
run: | | ||
source uhd.sh | ||
uhd lambda restart-functions | ||
shell: zsh {0} | ||
|
||
bootstrap_database: | ||
name: Bootstrap database | ||
runs-on: ubuntu-latest | ||
needs: [ "restart_services" ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials for tools account | ||
uses: ./.github/actions/configure-aws-credentials | ||
with: | ||
aws-region: ${{ env.AWS_REGION }} | ||
tools-account-role: ${{ secrets.UHD_TERRAFORM_IAM_ROLE }} | ||
|
||
- uses: ./.github/actions/setup-terraform | ||
- uses: ./.github/actions/setup-zsh | ||
|
||
- name: Terraform output | ||
run: | | ||
source uhd.sh | ||
uhd terraform init:layer 20-app | ||
uhd terraform output ${{ inputs.name }} | ||
shell: zsh {0} | ||
|
||
- name: Configure AWS credentials for dev account | ||
uses: ./.github/actions/configure-aws-credentials | ||
with: | ||
account-name: "dev" | ||
aws-region: ${{ env.AWS_REGION }} | ||
dev-account-role: ${{ secrets.UHD_TERRAFORM_ROLE_DEV }} | ||
|
||
- name: Bootstrap app database with truncated test dataset | ||
run: | | ||
source uhd.sh | ||
uhd ecs run-and-wait bootstrap-env | ||
shell: zsh {0} | ||
|
||
flush_caches: | ||
name: Flush caches | ||
runs-on: ubuntu-latest | ||
needs: ["bootstrap_database"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup-terraform | ||
- uses: ./.github/actions/setup-zsh | ||
|
||
- name: Configure AWS credentials for tools account | ||
uses: ./.github/actions/configure-aws-credentials | ||
with: | ||
aws-region: ${{ env.AWS_REGION }} | ||
tools-account-role: ${{ secrets.UHD_TERRAFORM_IAM_ROLE }} | ||
|
||
- name: Terraform output | ||
run: | | ||
source uhd.sh | ||
uhd terraform init:layer 20-app | ||
uhd terraform output ${{ inputs.name }} | ||
shell: zsh {0} | ||
|
||
- name: Configure AWS credentials for account | ||
uses: ./.github/actions/configure-aws-credentials | ||
with: | ||
account-name: "dev" | ||
aws-region: ${{ env.AWS_REGION }} | ||
dev-account-role: ${{ secrets.UHD_TERRAFORM_ROLE_DEV }} | ||
|
||
- name: Flush caches | ||
run: | | ||
source uhd.sh | ||
uhd cache flush | ||
shell: zsh {0} | ||
|
||
- name: Restart front end | ||
run: | | ||
source uhd.sh | ||
uhd ecs restart-containers front_end | ||
shell: zsh {0} |
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
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