WordPress-Coding-Standards/.github/workflows/manage-labels.yml
jrfnl b4fa525e4c
GH Actions: "pin" all action runners
Recently there has been more and more focus on securing GH Actions workflows - in part due to some incidents.

The problem with "unpinned" action runners is as follows:
* Tags are mutable, which means that a tag could point to a safe commit today, but to a malicious commit tomorrow.
    Note that GitHub is currently beta-testing a new "immutable releases" feature (= tags and release artifacts can not be changed anymore once the release is published), but whether that has much effect depends on the ecosystem of the packages using the feature.
    Aside from that, it will likely take years before all projects adopt _immutable releases_.
* Action runners often don't even point to a tag, but to a branch, making the used action runner a moving target.
    _Note: this type of "floating major" for action runners used to be promoted as good practice when the ecosystem was "young". Insights have since changed._

While it is convenient to use "floating majors" of action runners, as this means you only need to update the workflows on a new major release of the action runner, the price is higher risk of malicious code being executed in workflows.

Dependabot, by now, can automatically submit PRs to update pinned action runners too, as long as the commit-hash pinned runner is followed by a comment listing the released version the commit is pointing to.

So, what with Dependabot being capable of updating workflows with pinned action runners, I believe it is time to update the workflows to the _current_ best practice of using commit-hash pinned action runners.

The downside of this change is that there will be more frequent Dependabot PRs.

If this would become a burden/irritating, the following mitigations can be implemented:
1. Updating the Dependabot config to group updates instead of sending individual PRs per action runner.
2. A workflow to automatically merge Dependabot PRs as long as CI passes.

Ref: https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions
2025-09-20 02:12:07 +02:00

56 lines
1.6 KiB
YAML

name: Remove outdated labels
on:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
pull_request_target:
types:
- closed
issues:
types:
- closed
jobs:
on-pr-merge:
runs-on: ubuntu-latest
if: github.repository_owner == 'WordPress' && github.event.pull_request.merged == true
name: Clean up labels on PR merge
steps:
- uses: mondeja/remove-labels-gh-action@b7118e4ba5dca74acf1059b3cb7660378ff9ab1a # v2.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
labels: |
Status: Awaiting feedback
Status: Review ready
on-pr-close:
runs-on: ubuntu-latest
if: github.repository_owner == 'WordPress' && github.event_name == 'pull_request_target' && github.event.pull_request.merged == false
name: Clean up labels on PR close
steps:
- uses: mondeja/remove-labels-gh-action@b7118e4ba5dca74acf1059b3cb7660378ff9ab1a # v2.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
labels: |
Status: Awaiting feedback
Status: Close candidate
Status: Review ready
on-issue-close:
runs-on: ubuntu-latest
if: github.repository_owner == 'WordPress' && github.event.issue.state == 'closed'
name: Clean up labels on issue close
steps:
- uses: mondeja/remove-labels-gh-action@b7118e4ba5dca74acf1059b3cb7660378ff9ab1a # v2.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
labels: |
Status: Awaiting feedback
Status: Close candidate
Status: Good first issue
Status: Help wanted