From e535e14da6f13f7514564333ec0c6e48825a834c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 16 Jul 2025 00:56:03 +0200 Subject: [PATCH 1/2] GH Actions: auto-label new PRs Similar workflow as the one used in the main PHP_CodeSniffer repo to auto-apply some labels based on the contents of new PRs. Ref: https://github.com/srvaroa/labeler --- .github/labeler.yml | 25 +++++++++++++++ .github/workflows/label-new-prs.yml | 49 +++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/label-new-prs.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..37c8b7e --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,25 @@ +version: 1 +appendOnly: true +labels: + - label: "Status: triage" + draft: false + author-can-merge: false + + - label: "Component: Website" + draft: false + files: + - "src/.*" + + - label: "Component: Wiki" + draft: false + files: + - "build/wiki-command-replacer.sh" + - "build/wiki-code-samples/.*" + - "wiki/.*" + + - label: "Type: chores/QA/automation" + draft: false + files: + - ".yamllint.yml" + - ".github/.*" + - "build/wiki-command-replacer.sh" diff --git a/.github/workflows/label-new-prs.yml b/.github/workflows/label-new-prs.yml new file mode 100644 index 0000000..6ce48b8 --- /dev/null +++ b/.github/workflows/label-new-prs.yml @@ -0,0 +1,49 @@ +name: Label new PRs + +on: + # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target + # The `pull_request_target` event is used for "normal" PRs to label them when they are opened. + # This will use the `labeler.yml` file in the default (main) branch of the repo. + pull_request_target: + types: + - opened + - ready_for_review + + # The `pull_request` event is used for PRs which change the files which handle the labeling to prevent a silently failing action. + # This will use the `labeler.yml` file in the PR branch. + pull_request: + paths: + - '.github/workflows/label-new-prs.yml' + - '.github/labeler.yml' + +jobs: + label-new-prs: + runs-on: ubuntu-latest + if: github.repository_owner == 'PHPCSStandards' && github.event_name == 'pull_request_target' + + name: Add labels to new PRs + + steps: + - name: Label new PRs + uses: srvaroa/labeler@v1 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + validate-labeler-worflow: + runs-on: ubuntu-latest + if: github.repository_owner == 'PHPCSStandards' && github.event_name == 'pull_request' && github.event.pull_request.merged == false + + name: Validate changes to Labeler logic + + steps: + # Checkout is needed to use the `use_local_config` option. + - name: Checkout code + uses: actions/checkout@v4 + + - name: Verify changes to the labeling logic + uses: srvaroa/labeler@v1 + with: + use_local_config: true + fail_on_error: true + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" From f0c5719b0f716721319ba0875d04f740699f3653 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 16 Jul 2025 00:50:12 +0200 Subject: [PATCH 2/2] GH Actions: automate some label management This is a quite straight-forward workflow to just remove some labels which should only be on open issues/open PRs and which should be removed once an issue or PR has been closed/merged. Just attempting to reduce some manual labour. --- .github/workflows/label-remove-outdated.yml | 79 +++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/label-remove-outdated.yml diff --git a/.github/workflows/label-remove-outdated.yml b/.github/workflows/label-remove-outdated.yml new file mode 100644 index 0000000..b40c953 --- /dev/null +++ b/.github/workflows/label-remove-outdated.yml @@ -0,0 +1,79 @@ +name: Remove outdated labels + +on: + # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target + issues: + types: + - closed + pull_request_target: + types: + - closed + - review_requested + +jobs: + on-issue-close: + runs-on: ubuntu-latest + if: github.repository_owner == 'PHPCSStandards' && github.event.issue.state == 'closed' + + name: Clean up labels on issue close + + steps: + - uses: mondeja/remove-labels-gh-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + Status: awaiting feedback + Status: close candidate + Status: help wanted + Status: needs investigation + Status: triage + + on-pr-review-request: + runs-on: ubuntu-latest + if: github.repository_owner == 'PHPCSStandards' && github.event.action == 'review_requested' + + name: "Clean up labels on PR (re-)review request" + + steps: + - uses: mondeja/remove-labels-gh-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + Status: awaiting feedback + + on-pr-merge: + runs-on: ubuntu-latest + if: github.repository_owner == 'PHPCSStandards' && github.event.pull_request.merged == true + + name: Clean up labels on PR merge + + steps: + - uses: mondeja/remove-labels-gh-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + Status: awaiting feedback + Status: close candidate + Status: has merge conflict + Status: help wanted + Status: needs investigation + Status: triage + Status: wait for PHPCS 4.0.0 release + + on-pr-close: + runs-on: ubuntu-latest + # yamllint disable-line rule:line-length + if: github.repository_owner == 'PHPCSStandards' && github.event_name == 'pull_request_target' && github.event.action == 'closed' && github.event.pull_request.merged == false + + name: Clean up labels on PR close + + steps: + - uses: mondeja/remove-labels-gh-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + Status: awaiting feedback + Status: close candidate + Status: help wanted + Status: needs investigation + Status: triage