From 6318f680c5556e9f5d9cebe109e1cf7719088ba8 Mon Sep 17 00:00:00 2001 From: Tommy Gatti Date: Fri, 15 Mar 2024 13:48:03 +1100 Subject: [PATCH] Added pr-closed.yml: Responsible for Prerelease cleanup after PR closed --- .github/workflows/pr-closed.yml | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/pr-closed.yml diff --git a/.github/workflows/pr-closed.yml b/.github/workflows/pr-closed.yml new file mode 100644 index 0000000..5d904de --- /dev/null +++ b/.github/workflows/pr-closed.yml @@ -0,0 +1,42 @@ +name: PR Closed Cleanup +# Remove prereleases that were part of a closed PR, so we save space +# on our deployment targets. If needed, one can still get the +# spack.yaml as part of the closed PR and revive it themselves. +on: + pull_request: + types: + - closed + branches: + - main + - backport/*.* + paths: + - config/** + - spack.yaml +env: + SPACK_YAML_MODEL_YQ: .spack.specs[0] +jobs: + get-prerelease-tag-pattern: + name: Get Prerelease Tag Pattern + # Get the tag name from the `spack.yaml` that was in the PR that was closed + # which is of the form `access-om2@git.`. + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag.outputs.name }} + steps: + - uses: actions/checkout@v4 + + - name: Get Tag + id: tag + # Get the tag name from the access-om2 spec in the `spack.yaml`. + run: | + access_om2_package=$(yq e '${{ env.SPACK_YAML_MODEL_YQ }}' spack.yaml) + echo "name=${access_om2_package/*@git./}" >> $GITHUB_OUTPUT + + undeploy-prereleases: + name: Undeploy Prereleases + needs: + - get-prerelease-tag-pattern + uses: access-nri/build-cd/.github/workflows/undeploy-1-setup.yml@main + with: + version-pattern: ${{ needs.get-prerelease-tag-pattern.outputs.tag }}-* + secrets: inherit