From e3763e5cf314885d63584b44a634ba4fc92f623a Mon Sep 17 00:00:00 2001 From: Jason Lantz Date: Sun, 15 Sep 2024 11:49:10 -0500 Subject: [PATCH] Add 10 second delay to check should run logic if the triggering event is a PR to allow time for a push event to register. Add debugging output to Start Snapshot step --- .github/workflows/feature-test-2gp-snapshot.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/feature-test-2gp-snapshot.yml b/.github/workflows/feature-test-2gp-snapshot.yml index 0aced2d..f1eccd8 100644 --- a/.github/workflows/feature-test-2gp-snapshot.yml +++ b/.github/workflows/feature-test-2gp-snapshot.yml @@ -60,6 +60,8 @@ jobs: run: | # Get the commit SHA if [[ "${{ inputs.triggering_event }}" == "pull_request" ]]; then + # Delay for 10 seconds to prevent race conditions + sleep 10 SHA="${{ github.event.pull_request.head.sha }}" else SHA="${{ github.sha }}" @@ -152,13 +154,22 @@ jobs: if: inputs.create_pr_snapshot == true id: start_snapshot_creation run: | + set -e output=$(cci task run github_pull_request_snapshot \ --wait False \ --build-success ${{ job.status == 'success' }} \ - --snapshot-is-packaged true) + --snapshot-is-packaged true) || { + echo "Snapshot creation failed." + exit 1 + } echo "$output" snapshot_id=$(echo "$output" | grep -oP 'SNAPSHOT_ID=\K[^ ]+') - echo "SNAPSHOT_ID=$snapshot_id" >> $GITHUB_OUTPUT + if [ -n "$snapshot_id" ]; then + echo "SNAPSHOT_ID=$snapshot_id" >> $GITHUB_OUTPUT + else + echo "No SNAPSHOT_ID found in the output." + exit 1 + fi shell: bash - name: Run Feature Test