Skip to content

DDLS-224 : Add a check for submitted reports in report review page #142

DDLS-224 : Add a check for submitted reports in report review page

DDLS-224 : Add a check for submitted reports in report review page #142

name: "[Workflow] Destroy ephemeral environment"
permissions:
id-token: write
contents: read
security-events: none
pull-requests: write
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
jobs:
workspace_name:
runs-on: ubuntu-latest
name: output workflow variables
outputs:
build_identifier: ${{ steps.variables.outputs.build_identifier }}
steps:
- uses: actions/checkout@b32f140b0c872d58512e0a66172253c302617b90 # pin@v3
- name: extract variables for workflow
id: variables
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
export BRANCH=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF##*/}} | awk -F'_' '{print $1}' | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]' | cut -c1-8)
echo "build_identifier=$(echo ${BRANCH}${PR_NUMBER})" >> $GITHUB_OUTPUT
cleanup_workspace:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs:
- workspace_name
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- id: terraform_version
name: get terraform version
uses: ministryofjustice/opg-github-actions/.github/actions/terraform-version@v3.0.3
with:
terraform_directory: terraform/environment
- uses: hashicorp/setup-terraform@1b93182764c8332e7679b2393cb307cbe7baf9dc # pin@v2.0.0
with:
terraform_version: ${{ steps.terraform_version.outputs.version }}
terraform_wrapper: false
- uses: webfactory/ssh-agent@fd34b8dee206fe74b288a5e61bc95fba2f1911eb # pin@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_ALLOW_LIST_REPOSITORY }}
- name: configure OIDC AWS credentials for terraform
uses: aws-actions/configure-aws-credentials@b140ab7b246475139f89894ebae4ba00bd5b374e
with:
role-to-assume: arn:aws:iam::631181914621:role/oidc-digideps-development
role-session-name: github-actions-terraform
role-duration-seconds: 3600
aws-region: eu-west-1
- name: clean up environment
working-directory: ./terraform/environment
env:
WORKSPACE: ${{ needs.workspace_name.outputs.build_identifier }}
TF_VAR_OPG_DOCKER_TAG: foo
run: |
echo "Running script against ${WORKSPACE}"
./scripts/destroy_workspace.sh ${WORKSPACE}