Skip to content

Commit

Permalink
[WFLY-19889] Record status of workflow_run job on PR. It doesn't show…
Browse files Browse the repository at this point in the history
… up automatically
  • Loading branch information
kabir committed Oct 28, 2024
1 parent dcbc26d commit 2ae37ff
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion .github/workflows/cloud-test-pr-workflow-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,43 @@ jobs:
text="$(cat .job-env)"
echo "${text}"
echo "${text}" >> "$GITHUB_ENV"
- name: Report Progress
# This workflow_run job is invisible on the pull requests, so we need to report back whether we work
# or fail.
# We do that by reporting back via the same mechanism as the remote cloud test does.
if: ${{ env.TOKEN }}
run: |
STATUS="pending"
RUN_URL="https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
DESC="Invoking remote job"
CLIENT_PAYLOAD=$( jq -n \
--arg prHeadSha "$PR_HEAD_SHA" \
--arg state "$STATUS" \
--arg runUrl "$RUN_URL" \
--arg desc "$DESC" \
'{prHeadSha: $prHeadSha, state: $state, runUrl: $runUrl, desc: $desc}' )
echo "CLIENT_PAYLOAD: $CLIENT_PAYLOAD"
set -x
resp=$(curl -X POST -s "https://api.github.com/repos/${TRIGGER_REPOSITORY}/dispatches" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
-d "{\"event_type\": \"${REPORTER_EVENT_TYPE}\", \"client_payload\": ${CLIENT_PAYLOAD} }")
set +x
if [ -z "$resp" ]
then
sleep 2
else
echo "Workflow failed to trigger"
echo "$resp"
exit 1
fi
- name: Remote Dispatch
env:
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
Expand All @@ -62,7 +99,7 @@ jobs:
--arg prHeadSha "$GITHUB_EVENT_PULL_REQUEST_HEAD_SHA" \
--arg pr "$PR_NUMBER" \
'{triggerRepo: $tr, githubSha: $githubSha, prHeadSha: $prHeadSha, pr: $pr}' )
echo "CLIENT_PAYLOAD: $CLIENT_PAYLOAD"
set -x
Expand All @@ -84,3 +121,30 @@ jobs:
exit 1
fi
- name: Remote Dispatch to report failure
if: ${{ env.TOKEN }} && ${{ failure() }}
run: |
TEXT="The attempt to start the remote job failed, or was cancelled"
RUN_URL="https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
CLIENT_PAYLOAD=$( jq -n \
--arg prHeadSha "$PR_HEAD_SHA" \
--arg state "$STATUS" \
--arg runUrl "$RUN_URL" \
--arg desc "$TEXT" \
'{prHeadSha: $prHeadSha, state: $state, runUrl: $runUrl, desc: $desc}' )
echo "CLIENT_PAYLOAD: $CLIENT_PAYLOAD"
resp=$(curl -X POST -s "https://api.github.com/repos/${TRIGGER_REPOSITORY}/dispatches" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
-d "{\"event_type\": \"${REPORTER_EVENT_TYPE}\", \"client_payload\": ${CLIENT_PAYLOAD} }")
if [ -z "$resp" ]
then
sleep 2
else
echo "Workflow failed to trigger"
echo "$resp"
exit 1
fi

0 comments on commit 2ae37ff

Please sign in to comment.