From ad8608412fb5dbb287fc0a1c9017a1bcc362b33b Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Sat, 12 Sep 2026 21:52:28 +0800 Subject: [PATCH] chore: replace labeler workflows with Carson's auto-labeler and conflicts-notifier --- .github/carson.yml | 24 +++++++++ .github/labeler.yml | 23 --------- .../workflows/label-add-conflict-all-pr.yml | 51 ------------------- .github/workflows/label-pr.yml | 47 ----------------- .github/workflows/run-carson.yml | 10 ++++ 5 files changed, 34 insertions(+), 121 deletions(-) delete mode 100644 .github/labeler.yml delete mode 100644 .github/workflows/label-add-conflict-all-pr.yml delete mode 100644 .github/workflows/label-pr.yml diff --git a/.github/carson.yml b/.github/carson.yml index 8b7b3df521c2..169ec94a8477 100644 --- a/.github/carson.yml +++ b/.github/carson.yml @@ -2,8 +2,32 @@ version: 1 subscribers: + - auto-labeler + - conflicts-notifier - pr-title-linter settings: + auto-labeler: + sync_labels: true + rules: + - label: '4.8' # @todo change value whenever the next minor version is changed + base_branch: ['^4\.8$'] + - label: github_actions + files: ['.github/workflows/*'] + - label: documentation + files: + all: ['user_guide_src/source/**'] + - label: testing + files: + all: ['tests/**'] + conflicts-notifier: + label: stale + message: |- + :wave: Hi, @{{user}}! + + We detected conflicts in your PR against the base branch :speak_no_evil: + You may want to sync :arrows_counterclockwise: your branch with upstream! + + Ref: [Syncing Your Branch](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#updating-your-branch) pr-title-linter: name: 'Carson / pr-title-linter' rules: diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index 69cb0c51e123..000000000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,23 +0,0 @@ -# https://github.com/actions/labeler?tab=readme-ov-file#usage - -# Add the `4.8` label to PRs that target the `4.8` branch. -'4.8': # @todo change value whenever the next minor version is changed -- base-branch: '4.8' - -# Add the `github_actions` label to PRs that change any file in the `.github/workflows/` directory. -'github_actions': -- changed-files: - - any-glob-to-any-file: - - '.github/workflows/*' - -# Add the `documentation` label to PRs for documentation only. -'documentation': -- changed-files: - - any-glob-to-all-files: - - 'user_guide_src/source/**' - -# Add the `testing` label to PRs that changes tests only. -'testing': -- changed-files: - - any-glob-to-all-files: - - 'tests/**' diff --git a/.github/workflows/label-add-conflict-all-pr.yml b/.github/workflows/label-add-conflict-all-pr.yml deleted file mode 100644 index f9adde8207de..000000000000 --- a/.github/workflows/label-add-conflict-all-pr.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Auto Label "stale" for All PRs - -on: - push: - branches: - - develop - - '4.*' - -jobs: - build: - name: Check Conflicts - - permissions: - contents: read - pull-requests: write - - runs-on: ubuntu-24.04 - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Get PR List - id: PR-list - run: echo "pr_list=$(gh pr list -L 100 --json mergeable,url,labels,author)" >> $GITHUB_OUTPUT - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: 'Add label "stale" and comment' - env: - PR_LIST: ${{ steps.PR-list.outputs.pr_list }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - - IFS=$'\n' # Set Internal Field Separator to newline to handle array elements - - # Iterate through the PRs in PR_LIST - for pr in $(echo "$PR_LIST" | jq -c '.[]'); do - mergeable=$(echo "$pr" | jq -r '.mergeable') - author=$(echo "$pr" | jq -r '.author.login') - labels=$(echo "$pr" | jq -c '.labels[].name' | tr -d '[]"') - url=$(echo "$pr" | jq -r '.url') - - # CONFLICTING and no 'stale' label - if [ "$mergeable" == "CONFLICTING" ] && [[ ! "$labels" == *"stale"* ]]; then - # Add "stale" label - gh pr edit $url --add-label "stale" - - # Add a comment - gh pr comment $url --body ":wave: Hi, @$author!

We detected conflicts in your PR against the base branch :speak_no_evil:
You may want to sync :arrows_counterclockwise: your branch with upstream!

Ref: [Syncing Your Branch](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#updating-your-branch)" - fi - done diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml deleted file mode 100644 index bb84e2ad3504..000000000000 --- a/.github/workflows/label-pr.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Add Labels to PRs - -# NOTE: When updating this workflow, you should first change the event to `pull_request` to test the changes -# in a PR, and then change it back to `pull_request_target` before merging. -# @see https://github.com/actions/labeler?tab=readme-ov-file#updating-major-version-of-the-labeler -on: - - pull_request_target - -jobs: - add-labels: - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-24.04 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - name: Verify PR source for workflow file changes - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - script: | - const prFiles = await github.paginate(github.rest.pulls.listFiles.endpoint.merge({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - })); - const workflowFileChanged = prFiles.some(file => file.filename === '.github/workflows/label-pr.yml'); - - if (workflowFileChanged) { - if (context.payload.pull_request.head.repo.full_name !== 'codeigniter4/CodeIgniter4') { - throw new Error('Changes to label-pr.yml are not allowed from forks.'); - } - - console.log('Workflow file changed, but PR is from the main repository. Proceeding with label addition.'); - return; - } - - console.log('No changes to workflow file detected, proceeding with label addition.'); - - - name: Add labels - uses: actions/labeler@bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13 # v7.0.0 - with: - sync-labels: true # Remove labels when matching files are reverted diff --git a/.github/workflows/run-carson.yml b/.github/workflows/run-carson.yml index 44a30afa7c99..3a5a3e845d29 100644 --- a/.github/workflows/run-carson.yml +++ b/.github/workflows/run-carson.yml @@ -7,6 +7,16 @@ on: - edited - synchronize - reopened + - labeled + issues: + types: + - opened + - edited + - labeled + push: + branches: + - develop + - '4.*' permissions: {}