From 2678e26cd0b6ae4ac14f7ce75902fe3e0b1bc30b Mon Sep 17 00:00:00 2001 From: Micaiah Martin Date: Tue, 22 Oct 2024 09:20:05 -0600 Subject: [PATCH] Move to more robust logic --- .github/workflows/cleanup-ephemeral-environment.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cleanup-ephemeral-environment.yml b/.github/workflows/cleanup-ephemeral-environment.yml index f573d7056..d87b48ab0 100644 --- a/.github/workflows/cleanup-ephemeral-environment.yml +++ b/.github/workflows/cleanup-ephemeral-environment.yml @@ -8,24 +8,27 @@ jobs: validate-pr: name: Validate PR runs-on: ubuntu-24.04 + outputs: + config-exists: ${{ steps.validate-config.outputs.config-exists }} steps: - name: Checkout PR uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Validate config existed on branch + id: validate-config run: | # Search the git history for config files, exit if not found. - if [[ -z $(git rev-list --all -- "ephemeral-environments/$GITHUB_HEAD_REF.yaml") ]]; then - echo "No ephemeral environment config found on branch, exiting." - exit 1 + if [[ -n $(git rev-list --all -- "ephemeral-environments/$GITHUB_HEAD_REF.yaml") ]]; then + echo "Ephemeral environment config found on branch, continuing." + echo "config-exists=true" >> $GITHUB_OUTPUT fi - echo "Ephemeral environment config found on branch, continuing." cleanup-config: name: Cleanup ephemeral environment runs-on: ubuntu-24.04 needs: validate-pr + if: ${{ needs.validate-pr.outputs.config-exists }} steps: - name: Log in to Azure - CI subscription uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0