From d28ac714e8581d3c0dc84d375e5be1c79d4930da Mon Sep 17 00:00:00 2001 From: paoloredis Date: Fri, 1 Aug 2025 14:53:02 +0200 Subject: [PATCH 1/3] Add workflow that autocomments jira link --- .github/workflows/autocomment_jira_link.yaml | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/autocomment_jira_link.yaml diff --git a/.github/workflows/autocomment_jira_link.yaml b/.github/workflows/autocomment_jira_link.yaml new file mode 100644 index 0000000000..82858d1a95 --- /dev/null +++ b/.github/workflows/autocomment_jira_link.yaml @@ -0,0 +1,53 @@ +name: autocomment_jira_link + +on: + pull_request: + paths: + - 'content/**' + types: + - opened +permissions: + pull-requests: write + contents: read + +jobs: + auto-comment: + runs-on: ubuntu-latest + steps: + - name: 'Checkout' + uses: 'actions/checkout@v3' + + - name: Create Comment + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + REPO: ${{ github.repository }} + BRANCH_NAME: ${{ github.event.pull_request.head.ref }} + run: | + set -e + + CREATE_COMMENT_URL="https://api.github.com/repos/${REPO}/issues/${PR_NUMBER}/comments" + + JIRA_LINK="https://redislabs.atlassian.net/browse/${BRANCH_NAME}" + COMMENT="[${BRANCH_NAME}](${JIRA_LINK})" + + generate_post_data() + { + cat </dev/null + + printf '%s\n' 'Comment written!' + fi \ No newline at end of file From e535dc313445ffc61166609c56d4224166630a68 Mon Sep 17 00:00:00 2001 From: paoloredis Date: Fri, 1 Aug 2025 15:10:17 +0200 Subject: [PATCH 2/3] Handle cases where branch name includes more than jira ticket --- .github/workflows/autocomment_jira_link.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/autocomment_jira_link.yaml b/.github/workflows/autocomment_jira_link.yaml index 82858d1a95..8438275fc1 100644 --- a/.github/workflows/autocomment_jira_link.yaml +++ b/.github/workflows/autocomment_jira_link.yaml @@ -28,7 +28,8 @@ jobs: CREATE_COMMENT_URL="https://api.github.com/repos/${REPO}/issues/${PR_NUMBER}/comments" - JIRA_LINK="https://redislabs.atlassian.net/browse/${BRANCH_NAME}" + JIRA_TICKET=$(grep -Eo '^DOC-[0-9]+' <<< "$BRANCH_NAME") + JIRA_LINK="https://redislabs.atlassian.net/browse/${JIRA_TICKET}" COMMENT="[${BRANCH_NAME}](${JIRA_LINK})" generate_post_data() From a6a7e7421f781b623daadd37980c064d49d0ca23 Mon Sep 17 00:00:00 2001 From: paoloredis Date: Fri, 1 Aug 2025 15:21:25 +0200 Subject: [PATCH 3/3] Use ticket id for link title --- .github/workflows/autocomment_jira_link.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autocomment_jira_link.yaml b/.github/workflows/autocomment_jira_link.yaml index 8438275fc1..ba526ad156 100644 --- a/.github/workflows/autocomment_jira_link.yaml +++ b/.github/workflows/autocomment_jira_link.yaml @@ -30,7 +30,7 @@ jobs: JIRA_TICKET=$(grep -Eo '^DOC-[0-9]+' <<< "$BRANCH_NAME") JIRA_LINK="https://redislabs.atlassian.net/browse/${JIRA_TICKET}" - COMMENT="[${BRANCH_NAME}](${JIRA_LINK})" + COMMENT="[${JIRA_TICKET}](${JIRA_LINK})" generate_post_data() {