Skip to content

Post WPT results

Post WPT results #946

name: Post WPT results
on:
workflow_run:
workflows: ["WPT"]
types: [completed]
permissions:
pull-requests: write
actions: read
contents: read
jobs:
post-results:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Checkout trusted scripts
uses: actions/checkout@v5
with:
ref: ${{ github.event.repository.default_branch }}
- name: Download WPT diff
uses: actions/download-artifact@v7
with:
name: wpt-diff
path: ./wpt/output
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Find pull request for WPT run
id: pull-request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
PR_NUMBER="$(gh api --paginate "repos/$REPO/pulls?state=open&per_page=100" --jq '.[] | select(.head.sha == env.HEAD_SHA) | .number' | head -n 1)"
if [ -z "$PR_NUMBER" ]; then
echo "No pull request targeting $REPO found for commit $HEAD_SHA; skipping."
echo "number=" >> "$GITHUB_OUTPUT"
else
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
fi
- name: Post results to PR description
if: steps.pull-request.outputs.number != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.pull-request.outputs.number }}
RUN_URL: ${{ github.event.workflow_run.html_url }}
run: python3 ./.github/scripts/wpt_diff_to_pr.py ./wpt/output/wptdiff.json