Skip to content

Commit 88fe6a2

Browse files
committed
Add an action to label/unlabel PRs with JIRA URIs
Also: add branch labels (e.g. ubi9) Signed-off-by: Jonathan Dowland <[email protected]>
1 parent c664d52 commit 88fe6a2

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/jiralabels.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Ensure GH PRs have a corresponding JIRA issue
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
env:
12+
GH_REPO: ${{ github.repository }}
13+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
NUM: ${{ github.event.pull_request.number }}
15+
16+
jobs:
17+
check-jira-uri:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check for required URI pattern
21+
id: check_uri
22+
env:
23+
PR_BODY: ${{ github.event.pull_request.body }}
24+
URIPAT: "https://issues.redhat.com/browse/OPENJDK-"
25+
run: |
26+
if echo "$PR_BODY" | grep -q "$URIPAT"; then
27+
echo "missing=false" >> $GITHUB_OUTPUT
28+
else
29+
echo "missing=true" >> $GITHUB_OUTPUT
30+
fi
31+
32+
- name: Apply label if URI missing
33+
if: steps.check_uri.outputs.missing == 'true'
34+
run: |
35+
gh pr edit "$NUM" --add-label "needs-jira-issue"
36+
exit 1 # fail workflow; must be resolved to green-light PR
37+
38+
- name: Remove label if URI present
39+
if: steps.check_uri.outputs.missing == 'false'
40+
run: gh pr edit "$NUM" --remove-label "needs-jira-issue"
41+
42+
label-branch:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Add branch label if missing
46+
run: gh pr edit "$NUM" --add-label "$GITHUB_BASE_REF"

0 commit comments

Comments
 (0)