UML-3547 introduced new feature flag - "paper_verification" with a de… #249
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: "[Workflow] Destroy ephemeral environment" | |
permissions: | |
contents: read | |
security-events: none | |
pull-requests: read | |
actions: none | |
checks: none | |
deployments: none | |
issues: none | |
packages: none | |
repository-projects: none | |
statuses: none | |
defaults: | |
run: | |
shell: bash | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- closed | |
paths: | |
- "service-*/**" | |
- "terraform/**" | |
- "scripts/**" | |
- ".github/workflows/**" | |
jobs: | |
workspace_name: | |
runs-on: ubuntu-latest | |
outputs: | |
workspace_name: ${{ steps.set_workspace_name.outputs.workspace_name }} | |
steps: | |
- name: Set safe branch name | |
id: safe_branch_name | |
uses: ministryofjustice/opg-github-actions/.github/actions/[email protected] | |
- name: Set workspace name | |
id: set_workspace_name | |
run: | | |
echo "workspace_name=${{ github.event.number }}${{ steps.safe_branch_name.outputs.safe }}" >> $GITHUB_OUTPUT | |
if: github.event.pull_request.merged == true | |
cleanup_workspace: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
needs: | |
- workspace_name | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set terraform version | |
id: set-terraform-version | |
uses: ministryofjustice/opg-github-actions/.github/actions/[email protected] | |
with: | |
terraform_directory: "./terraform/environment" | |
terraform_versions_file: ".terraform-version" | |
simple_file: true | |
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 | |
with: | |
terraform_version: ${{ steps.set-terraform-version.outputs.version }} | |
terraform_wrapper: false | |
- uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0 | |
with: | |
ssh-private-key: ${{ secrets.USE_AN_LPA_DEPLOY_KEY_PRIVATE_KEY }} | |
- name: configure AWS credentials for getting pagerduty token | |
uses: aws-actions/configure-aws-credentials@97834a484a5ab3c40fa9e2eb40fcf8041105a573 # [email protected] | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }} | |
role-to-assume: arn:aws:iam::367815980639:role/opg-use-an-lpa-ci | |
aws-region: eu-west-1 | |
role-duration-seconds: 1800 | |
role-session-name: OPGUseAnLPADevAssumeGithubAction | |
- name: set pagerduty token | |
run: | | |
export TF_VAR_pagerduty_token=$(aws secretsmanager get-secret-value --secret-id \ | |
pagerduty_api_key --region eu-west-1 | jq -r '.SecretString' 2>/dev/null) | |
echo "::add-mask::$TF_VAR_pagerduty_token" | |
echo TF_VAR_pagerduty_token=$TF_VAR_pagerduty_token >> $GITHUB_ENV | |
- name: configure AWS credentials for terraform | |
uses: aws-actions/configure-aws-credentials@97834a484a5ab3c40fa9e2eb40fcf8041105a573 # [email protected] | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }} | |
aws-region: eu-west-1 | |
role-duration-seconds: 3600 | |
role-session-name: OPGUseAnLPATerraformGithubAction | |
- name: Run workspace cleanup | |
working-directory: ./terraform/environment | |
env: | |
TF_VAR_pagerduty_token: ${{ env.TF_VAR_pagerduty_token }} | |
run: | | |
../../scripts/pipeline/workspace_cleanup/destroy_workspace.sh ${{ needs.workspace_name.outputs.workspace_name }} |