Change http basic auth for when service closed #342
Workflow file for this run
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: Delete Review App | |
on: | |
pull_request: | |
types: [closed] | |
branches: [main] | |
permissions: | |
deployments: write | |
jobs: | |
delete-review-app: | |
name: Delete Review App ${{ github.event.pull_request.number }} | |
concurrency: deploy_review_${{ github.event.pull_request.number }} | |
if: contains(github.event.pull_request.labels.*.name, 'deploy') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS_REVIEW }} | |
- name: Set Environment variables | |
run: | | |
terraform_version=$(awk '/{/{f=/^terraform/;next}f' terraform/aks/terraform.tf | grep -o [0-9\.]*) | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
TF_STATE_FILE=pr-$PR_NUMBER.tfstate | |
echo "DEPLOY_ENV=review-$PR_NUMBER" >> $GITHUB_ENV | |
echo "APP_NAME=pr-$PR_NUMBER" >> $GITHUB_ENV | |
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV | |
echo "TF_STATE_FILE=$TF_STATE_FILE" >> $GITHUB_ENV | |
echo "TERRAFORM_VERSION=$terraform_version" >> $GITHUB_ENV | |
pr_state_file=$(az storage blob list -c terraform-state \ | |
--account-name "s189t01ccbltfstatervsa" \ | |
--prefix $TF_STATE_FILE --query "[].name" -o tsv) | |
if [ ! -z "$pr_state_file" ]; then echo "TF_STATE_EXISTS=true" >> $GITHUB_ENV; fi; | |
# tf_vars_file=terraform/aks/config/review.tfvars.json | |
# echo "key_vault_name=$(jq -r '.key_vault_name' ${tf_vars_file})" >> $GITHUB_ENV | |
# echo "key_vault_app_secret_name=$(jq -r '.key_vault_app_secret_name' ${tf_vars_file})" >> $GITHUB_ENV | |
# echo "key_vault_infra_secret_name=$(jq -r '.key_vault_infra_secret_name' ${tf_vars_file})" >> $GITHUB_ENV | |
- name: Use Terraform ${{ env.TERRAFORM_VERSION }} | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: ${{ env.TERRAFORM_VERSION }} | |
- uses: DFE-Digital/github-actions/set-kubelogin-environment@master | |
if: env.TF_STATE_EXISTS == 'true' | |
with: | |
azure-credentials: ${{ secrets.AZURE_CREDENTIALS_REVIEW }} | |
- name: Terraform destroy | |
if: env.TF_STATE_EXISTS == 'true' | |
run: make review ci terraform-destroy | |
env: | |
TF_VAR_azure_sp_credentials_json: ${{ secrets.AZURE_CREDENTIALS_REVIEW }} | |
- name: Delete tf state file | |
if: env.TF_STATE_EXISTS == 'true' | |
run: | | |
az storage blob delete -c terraform-state --name ${{ env.TF_STATE_FILE }} \ | |
--account-name "s189t01ccbltfstatervsa" | |
- name: Update ${{ matrix.environment }} status | |
id: deactivate-env | |
if: ${{ always() && env.TF_STATE_EXISTS == 'true' }} | |
uses: bobheadxi/deployments@v1 | |
with: | |
step: deactivate-env | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: review-${{ env.PR_NUMBER }} |