File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ name : autocomment_jira_link
2+
3+ on :
4+ pull_request :
5+ paths :
6+ - ' content/**'
7+ types :
8+ - opened
9+ permissions :
10+ pull-requests : write
11+ contents : read
12+
13+ jobs :
14+ auto-comment :
15+ runs-on : ubuntu-latest
16+ steps :
17+ - name : ' Checkout'
18+ uses : ' actions/checkout@v3'
19+
20+ - name : Create Comment
21+ env :
22+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
23+ PR_NUMBER : ${{ github.event.pull_request.number }}
24+ REPO : ${{ github.repository }}
25+ BRANCH_NAME : ${{ github.event.pull_request.head.ref }}
26+ run : |
27+ set -e
28+
29+ CREATE_COMMENT_URL="https://api.github.com/repos/${REPO}/issues/${PR_NUMBER}/comments"
30+
31+ JIRA_TICKET=$(grep -Eo '^DOC-[0-9]+' <<< "$BRANCH_NAME")
32+ JIRA_LINK="https://redislabs.atlassian.net/browse/${JIRA_TICKET}"
33+ COMMENT="[${JIRA_TICKET}](${JIRA_LINK})"
34+
35+ generate_post_data()
36+ {
37+ cat <<EOF
38+ {
39+ "body": "$COMMENT"
40+ EOF
41+ }
42+
43+ if [[ "$BRANCH_NAME" == DOC-* ]]; then
44+ # Write comment on pull request
45+ curl -Ls \
46+ -X POST \
47+ -H "Accept: application/vnd.github+json" \
48+ -H "X-GitHub-Api-Version: 2022-11-28" \
49+ -H "Authorization: token ${GITHUB_TOKEN}" \
50+ $CREATE_COMMENT_URL \
51+ --data "$(generate_post_data)" 1>/dev/null
52+
53+ printf '%s\n' 'Comment written!'
54+ fi
You can’t perform that action at this time.
0 commit comments