2222 upload :
2323 runs-on : ubuntu-latest
2424 permissions :
25- checks : write
25+ statuses : write
2626 # Only run on manual dispatch,
2727 # OR if the parent run succeeded and was triggered by a PR.
2828 # Fork PRs run through so we can post a "skipped" commit status to the PR
@@ -207,11 +207,10 @@ jobs:
207207 echo "The above links should start working a minute or two after this job completes." >> $GITHUB_STEP_SUMMARY
208208
209209 - name : Report dev-build outcome to PR head
210- # Reach this step for any run that resolved a PR head SHA — both
211- # workflow_run (auto-triggered by Publish Dist) and workflow_dispatch
212- # (a maintainer manually dispatching a build). The step then either
213- # creates a "dev build" check-run on the PR head, or PATCHes the
214- # existing one so the row updates in place instead of stacking.
210+ # Post a commit status on the PR head SHA so a row appears in the PR
211+ # merge-box widget. Statuses are keyed by (sha, context) with
212+ # last-write-wins semantics, so a maintainer-triggered dispatch that
213+ # follows an earlier "Skipped" status updates the same row in place.
215214 if : |
216215 always() && (
217216 (github.event_name == 'workflow_run' && github.event.workflow_run.head_sha != '') ||
@@ -221,60 +220,31 @@ jobs:
221220 GH_TOKEN : ${{ github.token }}
222221 REPO : ${{ github.repository }}
223222 SHA : ${{ github.event.workflow_run.head_sha || steps.get-metadata.outputs.SHA }}
224- HEAD_REPO : ${{ github.event.workflow_run.head_repository.full_name }}
225223 IS_FORK : ${{ steps.fork-check.outputs.is_fork }}
226224 PR_NUM : ${{ steps.get-metadata.outputs.PR_NUM }}
227225 UPLOAD_OUTCOME : ${{ steps.commit-and-push.outcome }}
228226 RUN_ID : ${{ github.run_id }}
229227 run : |
230228 RUN_URL="https://github.com/${REPO}/actions/runs/${RUN_ID}"
229+ CONTRIBUTING_URL="https://github.com/${REPO}/blob/master/CONTRIBUTING.md#live-links-to-dev-builds"
231230
232231 if [ "${IS_FORK}" == "true" ]; then
233- TITLE="Skipped: PR is from a fork"
234- CONCLUSION="neutral"
235- SUMMARY=$(cat <<EOF
236- Dev builds are not automatically published for PRs from forks (\`${HEAD_REPO}\`) as a security policy.
237-
238- If you need a dev build for this PR, please **contact a maintainer** and ask them to trigger the *Upload dev build from PR* workflow manually via the Actions tab, providing this PR's number as input.
239- EOF
240- )
241- DETAILS_URL="${RUN_URL}"
232+ STATE="success"
233+ DESCRIPTION="Skipped — PR is from a fork. Ask a maintainer to trigger a build."
234+ TARGET_URL="${CONTRIBUTING_URL}"
242235 elif [ "${UPLOAD_OUTCOME}" == "success" ]; then
243- TITLE="Dev build available"
244- CONCLUSION="success"
245- URL="https://plotly.github.io/plotly.js-dev-builds/${UPLOAD_DIR_NAME}/pr-${PR_NUM}/latest/plotly.min.js"
246- SUMMARY="Latest dev build for PR #${PR_NUM}: [${URL}](${URL})"
247- DETAILS_URL="${URL}"
236+ STATE="success"
237+ DESCRIPTION="Latest dev builds for PR #${PR_NUM}"
238+ TARGET_URL="https://plotly.github.io/plotly.js-dev-builds/${UPLOAD_DIR_NAME}/pr-${PR_NUM}/latest"
248239 else
249- TITLE="Dev build upload failed"
250- CONCLUSION="failure"
251- SUMMARY="Upload workflow failed. See [the run](${RUN_URL}) for details."
252- DETAILS_URL="${RUN_URL}"
240+ STATE="failure"
241+ DESCRIPTION="Upload failed — see workflow run for details."
242+ TARGET_URL="${RUN_URL}"
253243 fi
254244
255- PAYLOAD=$(jq -n \
256- --arg conclusion "${CONCLUSION}" \
257- --arg title "${TITLE}" \
258- --arg summary "${SUMMARY}" \
259- --arg details_url "${DETAILS_URL}" \
260- '{
261- status: "completed",
262- conclusion: $conclusion,
263- details_url: $details_url,
264- output: {title: $title, summary: $summary}
265- }')
266-
267- # Look for an existing "dev build" check-run on this SHA so we can
268- # PATCH it in place — e.g. so an initial "Skipped: fork" row updates
269- # to "Dev build available" when a maintainer later dispatches a build.
270- # If multiple exist (shouldn't happen under normal use), PATCH the most
271- # recent one identified by the highest check-run id.
272- EXISTING_ID=$(gh api "repos/${REPO}/commits/${SHA}/check-runs" \
273- --jq '[.check_runs[] | select(.name == "dev build")] | sort_by(.id) | last | .id // empty')
274-
275- if [ -n "${EXISTING_ID}" ]; then
276- echo "${PAYLOAD}" | gh api --method PATCH --input - "repos/${REPO}/check-runs/${EXISTING_ID}"
277- else
278- echo "${PAYLOAD}" | jq --arg sha "${SHA}" '. + {name: "dev build", head_sha: $sha}' \
279- | gh api --method POST --input - "repos/${REPO}/check-runs"
280- fi
245+ jq -n \
246+ --arg state "${STATE}" \
247+ --arg description "${DESCRIPTION}" \
248+ --arg target_url "${TARGET_URL}" \
249+ '{state: $state, target_url: $target_url, description: $description, context: "dev build"}' \
250+ | gh api --method POST --input - "repos/${REPO}/statuses/${SHA}"
0 commit comments