Skip to content

Commit 79ae14f

Browse files
authored
Merge pull request #7959 from totoprayogo1916/conflicting
chore: Separate workflow to add/remove 'stale' label
2 parents 8847002 + 58acfec commit 79ae14f

File tree

3 files changed

+60
-45
lines changed

3 files changed

+60
-45
lines changed

.github/workflows/label-add-conflict.yml renamed to .github/workflows/label-add-conflict-all-pr.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
name: Auto Add Label "stale" & Comment Conflicts
1+
name: Auto Label "stale" for All PRs
22

33
on:
44
push:
55
branches:
66
- develop
77
- '4.*'
8-
pull_request:
9-
branches:
10-
- develop
11-
- '4.*'
128

139
jobs:
14-
auto-label-comment-conflict:
10+
build:
11+
name: Check Conflicts
1512

1613
permissions:
1714
contents: read
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Auto Label "stale"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
- '4.*'
8+
9+
jobs:
10+
build:
11+
name: Check Conflicts
12+
runs-on: ubuntu-22.04
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Get PR Detail
22+
id: PR-detail
23+
run: echo "detail=$(gh pr view $PR_URL --json mergeable,url,labels)" >> $GITHUB_OUTPUT
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
PR_URL: ${{ github.event.pull_request.html_url }}
27+
28+
- name: 'Remove label "stale"'
29+
env:
30+
PR_DETAIL: ${{ steps.PR-detail.outputs.detail }}
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
PR_URL: ${{ github.event.pull_request.html_url }}
33+
run: |
34+
35+
# MERGEABLE with 'stale' label
36+
if [ "$(echo $PR_DETAIL | jq -r '.mergeable')" == "MERGEABLE" ] && \
37+
[ "$(echo $PR_DETAIL | jq -r '.labels[] | select(.name == "stale")')" != "" ]; then
38+
# remove 'stale' label
39+
gh pr edit $PR_URL --remove-label "stale"
40+
fi
41+
42+
- name: 'Check for conflicts and add label/comment'
43+
env:
44+
PR_DETAIL: ${{ steps.PR-detail.outputs.detail }}
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
PR_URL: ${{ github.event.pull_request.html_url }}
47+
AUTHOR: ${{ github.event.pull_request.user.login }}
48+
run: |
49+
50+
# CONFLICTING with no "stale" label,
51+
if [ "$(echo $PR_DETAIL | jq -r '.mergeable')" == "CONFLICTING" ] && \
52+
[ "$(echo $PR_DETAIL | jq -r '.labels[] | select(.name == "stale")')" == "" ]; then
53+
# add label
54+
gh pr edit $PR_URL --add-label "stale"
55+
# add comment
56+
gh pr comment $PR_URL --body ":wave: Hi, @$AUTHOR!<br><br>We detected conflicts in your PR against the base branch :speak_no_evil:<br>You may want to sync :arrows_counterclockwise: your branch with upstream!<br><br>Ref: [Syncing Your Branch](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#pushing-your-branch)"
57+
fi

.github/workflows/label-remove-conflict.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)