-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Move "Test plugin upgrades" to a post-build workflow (#28241)
GitHub has an unfortunate behavior in that workflow artifacts are not available via the API until the entire workflow has completed. This means that the "Test plugin upgrades" job in the build workflow unnecessarily delays the availability of the build artifact for Jetpack Live Branches and future wpcom automated testing for 6 or so minutes. To get around this, we create a new "Post-Build" workflow that is triggered by `workflow_run` after the Build workflow completes. But since this new workflow isn't automatically attached to the PR, we have to make API calls to get it to show up there. This is a second attempt at #25892, which had to be reverted as using the Actions app put the checks into the "suite" of a random workflow.
- Loading branch information
Showing
6 changed files
with
390 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: "Check Run" | ||
description: "Create or update a check run. This is a simple wrapper around GitHub's checks API, https://docs.github.com/en/rest/checks/runs." | ||
inputs: | ||
id: | ||
description: "Check run ID to update. If not given, a new run will be created" | ||
sha: | ||
description: "The SHA of the commit." | ||
name: | ||
description: "The name of the check. For example, \"code-coverage\"." | ||
status: | ||
description: "The current status. Can be one of: `queued`, `in_progress`, `completed`" | ||
conclusion: | ||
description: "The final conclusion of the check. Can be one of: `action_required`, `cancelled`, `failure`, `neutral`, `success`, `skipped`, `timed_out`" | ||
title: | ||
description: "Title of the check. Shown in the PR's checks list." | ||
summary: | ||
description: "Summary of the check. Can contain Markdown." | ||
token: | ||
description: "App access token. See https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app for how to get one." | ||
outputs: | ||
id: | ||
description: "Check run ID." | ||
value: ${{ steps.run.outputs.id }} | ||
runs: | ||
using: composite | ||
steps: | ||
- id: run | ||
shell: bash | ||
env: | ||
ID: ${{ inputs.id }} | ||
SHA: ${{ inputs.sha }} | ||
NAME: ${{ inputs.name }} | ||
STATUS: ${{ inputs.status }} | ||
CONCLUSION: ${{ inputs.conclusion }} | ||
TITLE: ${{ inputs.title }} | ||
SUMMARY: ${{ inputs.summary }} | ||
TOKEN: ${{ inputs.token }} | ||
run: | | ||
if [[ -n "$ID" ]]; then | ||
METHOD=PATCH | ||
URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/check-runs/$ID" | ||
else | ||
METHOD=POST | ||
URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/check-runs" | ||
fi | ||
DATA="{}" | ||
if [[ -n "$NAME" ]]; then | ||
DATA="$(jq --arg v "$NAME" '.name |= $v' <<<"$DATA")" | ||
fi | ||
if [[ -n "$SHA" ]]; then | ||
DATA="$(jq --arg v "$SHA" '.head_sha |= $v' <<<"$DATA")" | ||
fi | ||
if [[ -n "$STATUS" ]]; then | ||
DATA="$(jq --arg v "$STATUS" '.status |= $v' <<<"$DATA")" | ||
fi | ||
if [[ -n "$CONCLUSION" ]]; then | ||
DATA="$(jq --arg v "$CONCLUSION" '.conclusion |= $v' <<<"$DATA")" | ||
fi | ||
if [[ -n "$TITLE" ]]; then | ||
DATA="$(jq --arg v "$TITLE" '.output.title |= $v' <<<"$DATA")" | ||
fi | ||
if [[ -n "$SUMMARY" ]]; then | ||
DATA="$(jq --arg v "$SUMMARY" '.output.summary |= $v' <<<"$DATA")" | ||
fi | ||
echo "Data: $DATA" | ||
JSON="$(curl -v -X "$METHOD" --header "authorization: Bearer $TOKEN" --url "$URL" --data "$DATA")" | ||
echo "$JSON" | ||
echo "id=$(jq -r .id <<<"$JSON")" >> "$GITHUB_OUTPUT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.