Skip to content

Commit d28ac71

Browse files
committed
Add workflow that autocomments jira link
1 parent 11e75ef commit d28ac71

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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_LINK="https://redislabs.atlassian.net/browse/${BRANCH_NAME}"
32+
COMMENT="[${BRANCH_NAME}](${JIRA_LINK})"
33+
34+
generate_post_data()
35+
{
36+
cat <<EOF
37+
{
38+
"body": "$COMMENT"
39+
EOF
40+
}
41+
42+
if [[ "$BRANCH_NAME" == DOC-* ]]; then
43+
# Write comment on pull request
44+
curl -Ls \
45+
-X POST \
46+
-H "Accept: application/vnd.github+json" \
47+
-H "X-GitHub-Api-Version: 2022-11-28" \
48+
-H "Authorization: token ${GITHUB_TOKEN}" \
49+
$CREATE_COMMENT_URL \
50+
--data "$(generate_post_data)" 1>/dev/null
51+
52+
printf '%s\n' 'Comment written!'
53+
fi

0 commit comments

Comments
 (0)