From 6151abe08a5abe4397a9a286bce40585725e562d Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Fri, 2 May 2025 18:05:26 +0200 Subject: [PATCH] ci: Add error handling for failed workflow run (#869) Enhance action to fail on non-successful workflow runs Add logic to check the conclusion of the watched workflow run. If the run ends with a non-successful status, the action now exits with an error to improve error handling and ensure reliability. Co-authored-by: Jason Wen --- .github/workflows/wait-for-action/action.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/wait-for-action/action.yaml b/.github/workflows/wait-for-action/action.yaml index 574ef1518..9cde4cf07 100644 --- a/.github/workflows/wait-for-action/action.yaml +++ b/.github/workflows/wait-for-action/action.yaml @@ -40,5 +40,13 @@ runs: RUN_ID=$(gh run list --workflow=${{ inputs.workflow }} --branch="$BRANCH" --limit=1 --json databaseId --jq '.[0].databaseId') echo "Watching run ID: $RUN_ID" gh run watch "$RUN_ID" + + CONCLUSION=$(gh run view "$RUN_ID" --json conclusion --jq '.conclusion') + echo "Run concluded with: $CONCLUSION" + + if [[ "$CONCLUSION" != "success" ]]; then + echo "❌ Workflow run failed with conclusion: $CONCLUSION" + exit 1 + fi env: GITHUB_TOKEN: ${{ inputs.github-token }}