File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
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"
You can’t perform that action at this time.
0 commit comments