Skip to content

Commit c9bb67b

Browse files
Separate workflow
1 parent 5712e6c commit c9bb67b

File tree

3 files changed

+57
-44
lines changed

3 files changed

+57
-44
lines changed

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
name: Auto Add Label "stale" & Comment Conflicts
1+
name: Auto Add Label "stale" & Comment Conflicts for All PR
22

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

139
jobs:
1410
auto-label-comment-conflict:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Auto Add/Remove "stale" label in single PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
- '4.*'
8+
9+
jobs:
10+
check-conflict:
11+
runs-on: ubuntu-22.04
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Get PR Detail
21+
id: PR-detail
22+
run: echo "detail=$(gh pr view $PR_URL --json mergeable,url,labels)" >> $GITHUB_OUTPUT
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
PR_URL: ${{ github.event.pull_request.html_url }}
26+
27+
- name: 'Remove label "stale"'
28+
env:
29+
PR_DETAIL: ${{ steps.PR-detail.outputs.detail }}
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
PR_URL: ${{ github.event.pull_request.html_url }}
32+
run: |
33+
34+
# MERGEABLE with 'stale' label
35+
if [ "$(echo $PR_DETAIL | jq -r '.mergeable')" == "MERGEABLE" ] && \
36+
[ "$(echo $PR_DETAIL | jq -r '.labels[] | select(.name == "stale")')" != "" ]; then
37+
# remove 'stale' label
38+
gh pr edit $PR_URL --remove-label "stale"
39+
fi
40+
41+
- name: 'Check for conflicts and add label/comment'
42+
env:
43+
PR_DETAIL: ${{ steps.PR-detail.outputs.detail }}
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
PR_URL: ${{ github.event.pull_request.html_url }}
46+
AUTHOR: ${{ github.event.pull_request.user.login }}
47+
run: |
48+
49+
# CONFLICTING with no "stale" label,
50+
if [ "$(echo $PR_DETAIL | jq -r '.mergeable')" == "CONFLICTING" ] && \
51+
[ "$(echo $PR_DETAIL | jq -r '.labels[] | select(.name == "stale")')" != "" ]; then
52+
# add label
53+
gh pr edit $PR_URL --add-label "stale"
54+
# add comment
55+
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)"
56+
fi

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

-39
This file was deleted.

0 commit comments

Comments
 (0)