Repository navigation
Shadow: Add a PHP helper for block support classes and styles #349265
Workflow file for this run
This file contains hidden or 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
| name: Props Bot | |
| on: | |
| # This event runs anytime a PR is (re)opened, updated, marked ready for review, or labeled. | |
| # GitHub does not allow filtering the `labeled` event by a specific label. | |
| # However, the logic below will short-circuit the workflow when the `props-bot` label is not the one being added. | |
| # Note: The pull_request_target event is used instead of pull_request because this workflow needs permission to comment | |
| # on the pull request. Because this event grants extra permissions to `GITHUB_TOKEN`, any code changes within the PR | |
| # should be considered untrusted. See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/. | |
| pull_request_target: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - labeled | |
| - ready_for_review | |
| # This event runs anytime a comment is added or deleted. | |
| # You cannot filter this event for PR comments only. | |
| # However, the logic below does short-circuit the workflow for issues. | |
| issue_comment: | |
| types: | |
| - created | |
| # This event will run everytime a new PR review is initially submitted. | |
| # Every inline comment and thread reply is submitted as part of a review, | |
| # so `pull_request_review_comment` would only add one run per comment. | |
| pull_request_review: | |
| types: | |
| - submitted | |
| # Queues runs for a pull request in order, which keeps two gathers from writing | |
| # their lists out of order. Runs wait for a runner for minutes at busy times, so | |
| # cancelling superseded ones instead left most events with a cancelled check. | |
| concurrency: | |
| # Keyed by the pull request, which each of the three events carries in a | |
| # different place. Two kinds of run stand apart, or they would hold up a | |
| # refresh while doing nothing themselves: a label event that is not | |
| # `props-bot`, whose jobs all skip, and a fork's review run, whose token | |
| # cannot write. | |
| group: ${{ github.workflow }}-${{ ( github.event.action != 'labeled' || github.event.label.name == 'props-bot' ) && ( github.event_name != 'pull_request_review' || github.event.pull_request.head.repo.full_name == github.repository ) && ( github.event.number || github.event.issue.number || github.event.pull_request.number ) || github.run_id }} | |
| cancel-in-progress: false | |
| # The default would still cancel a pending run once a newer one arrived. | |
| queue: max | |
| # Disable permissions for all available scopes by default. | |
| # Any needed permissions should be configured at the job level. | |
| permissions: {} | |
| env: | |
| # Sections are truncated at write from this commit on. A base without it, | |
| # a release branch or a stack cut before it, carries writers that would | |
| # re-cut the props list, so it keeps the standalone comment. | |
| PR_META_WRITERS_SHA: d5eff1a2e1201f8644b2732d46fe0320670ef93e | |
| # A review runs this file from the merge ref, so a target still carrying | |
| # the old routing would recreate the standalone comment. The resolve job | |
| # looks for this line in the target's copy. | |
| PROPS_ROUTING: pr-meta-props-routing-2 | |
| jobs: | |
| pull-request: | |
| name: Resolve the pull request target | |
| runs-on: 'ubuntu-slim' | |
| permissions: | |
| pull-requests: read | |
| # Reading the target's copy of this workflow. | |
| contents: read | |
| timeout-minutes: 5 | |
| outputs: | |
| routing-current: ${{ steps.pull-request.outputs.result }} | |
| # The job will run when pull requests are open, ready for review and: | |
| # | |
| # - A comment is added to the pull request. | |
| # - A review is submitted, including a single comment or thread reply. | |
| # - The pull request is opened, synchronized, marked ready for review, or reopened. | |
| # - The `props-bot` label is added to the pull request. | |
| # A fork's review run is skipped rather than gathered and thrown away: | |
| # its token cannot write the comment at the end of it. | |
| if: | | |
| ( | |
| github.event_name == 'issue_comment' && github.event.issue.pull_request || | |
| github.event_name == 'pull_request_review' && github.event.pull_request.head.repo.full_name == github.repository || | |
| github.event_name == 'pull_request_target' && github.event.action != 'labeled' || | |
| 'props-bot' == github.event.label.name | |
| ) && | |
| ( ! github.event.pull_request.draft && github.event.pull_request.state == 'open' || ! github.event.issue.draft && github.event.issue.state == 'open' ) | |
| steps: | |
| # issue_comment does not carry the target branch. Read the current | |
| # target for every event so both writers use the same decision. | |
| - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| id: pull-request | |
| with: | |
| result-encoding: string | |
| script: | | |
| const { data } = await github.rest.pulls.get( { | |
| ...context.repo, | |
| pull_number: context.issue.number, | |
| } ); | |
| // A target carrying this routing also holds `PR_META_WRITERS_SHA`. | |
| try { | |
| const { data: file } = await github.rest.repos.getContent( { | |
| ...context.repo, | |
| path: '.github/workflows/props-bot.yml', | |
| ref: data.base.ref, | |
| } ); | |
| return Buffer.from( file.content, 'base64' ) | |
| .toString() | |
| .includes( `PROPS_ROUTING: ${ process.env.PROPS_ROUTING }` ); | |
| } catch ( error ) { | |
| if ( error.status === 404 ) { | |
| return false; | |
| } | |
| throw error; | |
| } | |
| # Collects a list of contributor props for the PR meta comment to post. | |
| props-bot: | |
| name: Generate a list of props | |
| needs: pull-request | |
| if: ${{ needs.pull-request.outputs.routing-current == 'true' }} | |
| runs-on: 'ubuntu-slim' | |
| permissions: | |
| # Read is enough: the action posts nothing, see `post-comment`. | |
| pull-requests: read | |
| contents: read | |
| timeout-minutes: 20 | |
| outputs: | |
| comment-body: ${{ steps.props.outputs.comment-body }} | |
| steps: | |
| - name: Gather a list of contributors | |
| id: props | |
| uses: WordPress/props-bot-action@1cde16a46fe7a1bfa8e3bbbcb80647bb59756751 # trunk | |
| with: | |
| # The PR meta comment carries the list, so the action renders | |
| # it to an output and posts nothing itself. | |
| post-comment: false | |
| # The intro is what an older standalone props bot searches | |
| # for, and it would find this comment. Our own note about | |
| # refreshing replaces it, worded so that it will not. | |
| include-intro: false | |
| # Other branches retain standalone props until they carry this routing and | |
| # its writers. Otherwise the base gate would discard every fresh list. | |
| standalone-props: | |
| name: Update the standalone props comment | |
| needs: pull-request | |
| if: ${{ needs.pull-request.outputs.routing-current == 'false' }} | |
| runs-on: 'ubuntu-slim' | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: WordPress/props-bot-action@1cde16a46fe7a1bfa8e3bbbcb80647bb59756751 # trunk | |
| with: | |
| post-comment: true | |
| pr-meta: | |
| name: Update PR meta comment | |
| needs: props-bot | |
| # Only when the list was gathered: an empty body from a failed run would | |
| # clear a props list nothing had disproved. | |
| if: ${{ needs.props-bot.result == 'success' }} | |
| runs-on: 'ubuntu-slim' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| timeout-minutes: 5 | |
| # Shared with every other writer of this comment. See bundle-size.yml. | |
| # This workflow runs on three events, and only some of them carry the | |
| # pull request at the same place in the payload. | |
| concurrency: | |
| group: pr-meta-${{ github.event.number || github.event.issue.number || github.event.pull_request.number }} | |
| cancel-in-progress: false | |
| queue: max | |
| steps: | |
| # This job holds a writable token, and the review events check out | |
| # `refs/pull/N/merge` by default, which carries the pull request's | |
| # own code. Pin the action to the default branch so a pull request | |
| # cannot supply the code that runs here. | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| ref: ${{ github.event.repository.default_branch }} | |
| sparse-checkout: tools/pr-meta | |
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | |
| persist-credentials: false | |
| - name: Render the props list | |
| env: | |
| # Through the environment, never interpolated into the script. | |
| BODY: ${{ needs.props-bot.outputs.comment-body }} | |
| run: | | |
| mkdir -p pr-meta | |
| : > pr-meta/body.md | |
| # No contributors, so an empty body clears the section rather | |
| # than leaving one that holds nothing but the note. | |
| if [ -z "$BODY" ]; then | |
| exit 0 | |
| fi | |
| printf '%s\n' "$BODY" > pr-meta/body.md | |
| cat >> pr-meta/body.md <<'EOF' | |
| _Updated as activity occurs, without notifying anyone named here. Add the `props-bot` label to refresh._ | |
| EOF | |
| - uses: ./tools/pr-meta | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| section: props | |
| body-path: pr-meta/body.md | |
| # The action comes from the default branch, which need not | |
| # yet know where each of the three events carries this. | |
| pr-number: ${{ github.event.number || github.event.issue.number || github.event.pull_request.number }} | |
| # This workflow also runs from the default branch for a pull | |
| # request targeting a branch whose own writers are older and | |
| # would re-cut the section. They need the action before this | |
| # section may appear there. | |
| require-base-contains: ${{ env.PR_META_WRITERS_SHA }} | |
| # Retires the standalone comment on pull requests open before | |
| # this landed, so no one copies its list once it stops moving. | |
| # Editing a comment notifies nobody, so an unlinked | |
| # contributor is no longer pinged by this list. | |
| retire-comments-matching: 'The following accounts have interacted' |