-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CAPT-1632 Implement review apps (#2737)
Migration to AKS
- Loading branch information
AbigailMcP
authored
Jun 7, 2024
1 parent
49c1067
commit 929357a
Showing
28 changed files
with
524 additions
and
23 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 |
---|---|---|
|
@@ -16,3 +16,7 @@ localhost.key | |
|
||
**/.terraform | ||
.vscode | ||
|
||
.github | ||
azure | ||
terraform |
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,44 @@ | ||
name: Deploy environment | ||
description: Deploys an application environment | ||
|
||
inputs: | ||
environment: | ||
description: The name of the environment | ||
required: true | ||
docker-image: | ||
description: The Docker image to deploy | ||
required: true | ||
azure-credentials: | ||
description: JSON object containing a service principal that can read from Azure Key Vault | ||
required: true | ||
pull-request-number: | ||
description: The pull request number which triggered this deploy. | ||
required: false | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: 1.8.4 | ||
terraform_wrapper: false | ||
|
||
- uses: DFE-Digital/github-actions/set-kubelogin-environment@master | ||
with: | ||
azure-credentials: ${{ inputs.azure-credentials }} | ||
|
||
- name: Terraform Apply | ||
shell: bash | ||
run: | | ||
make ci ${{ inputs.environment }} terraform-apply-aks | ||
env: | ||
DOCKER_IMAGE_TAG: ${{ inputs.docker-image }} | ||
PR_NUMBER: ${{ inputs.pull-request-number }} | ||
|
||
- name: Extract Terraform outputs | ||
shell: bash | ||
id: set_outputs | ||
run: | | ||
output=$(terraform -chdir=terraform/application output -raw url) | ||
echo "APP_URL=$output" >> $GITHUB_ENV |
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,80 @@ | ||
name: Build and deploy to AKS cluster | ||
|
||
on: | ||
pull_request: | ||
types: [labeled, opened, reopened, synchronize] | ||
|
||
concurrency: deploy-${{ github.ref }} | ||
|
||
permissions: | ||
packages: write | ||
pull-requests: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }} | ||
outputs: | ||
docker-image-tag: ${{ steps.build-image.outputs.tag }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build and push docker image | ||
id: build-image | ||
uses: DFE-Digital/github-actions/build-docker-image@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
target: web | ||
context: . | ||
|
||
deploy_review: | ||
name: Deploy to review environment | ||
concurrency: deploy_review_${{ github.event.pull_request.number }} | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
environment: | ||
name: review-aks | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/deploy-environment | ||
id: deploy | ||
with: | ||
environment: review-aks | ||
docker-image: ${{ needs.build.outputs.docker-image-tag }} | ||
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} | ||
pull-request-number: ${{ github.event.pull_request.number }} | ||
|
||
- uses: azure/login@v2 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Set kubectl | ||
uses: DFE-Digital/github-actions/set-kubectl@master | ||
|
||
- name: Seed review app | ||
shell: bash | ||
if: github.event.number != '' | ||
run: | | ||
make ci review-aks get-cluster-credentials | ||
kubectl exec -n srtl-development deployment/claim-additional-payments-for-teaching-review-${{ github.event.pull_request.number }}-worker -- sh -c "DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bin/prepare-database" | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
|
||
- name: Post comment to Pull Request ${{ github.event.number }} | ||
if: ${{ github.event_name == 'pull_request' }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: aks | ||
message: | | ||
### Deployments | ||
| Journey | URL | | ||
| ------------------- | ------------------------------------ | | ||
| Additional Payments | <${{ env.APP_URL }}/additional-payments/claim> | | ||
| Student Loans | <${{ env.APP_URL }}/student-loans/claim> | | ||
| Admin | <${{ env.APP_URL }}/admin> | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Delete review app on AKS | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
delete-review-app: | ||
name: Delete review app ${{ github.event.pull_request.number }} | ||
concurrency: deploy_review_${{ github.event.pull_request.number }} | ||
runs-on: ubuntu-latest | ||
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }} | ||
environment: review-aks | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: 1.8.4 | ||
terraform_wrapper: false | ||
|
||
- uses: DFE-Digital/github-actions/set-kubelogin-environment@master | ||
with: | ||
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Terraform destroy | ||
run: | | ||
make ci review-aks terraform-destroy-aks | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plugin "terraform" { | ||
enabled = true | ||
preset = "recommended" | ||
} | ||
|
||
plugin "azurerm" { | ||
enabled = true | ||
version = "0.26.0" | ||
source = "github.com/terraform-linters/tflint-ruleset-azurerm" | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
terraform 1.2.4 | ||
terraform 1.8.4 | ||
ruby 3.2.4 | ||
nodejs 16.17.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
Empty file.
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
Oops, something went wrong.