DOC-5849 added draft redis-py failover page #287
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: autocomment_jira_link | |
| on: | |
| pull_request: | |
| 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: | | |
| generate_post_data() | |
| { | |
| cat <<EOF | |
| { | |
| "body": "$COMMENT" | |
| EOF | |
| } | |
| if [[ "$BRANCH_NAME" == DOC-* ]]; then | |
| CREATE_COMMENT_URL="https://api.github.com/repos/${REPO}/issues/${PR_NUMBER}/comments" | |
| JIRA_TICKET=$(grep -Eo '^DOC-[0-9]+' <<< "$BRANCH_NAME") | |
| JIRA_LINK="https://redislabs.atlassian.net/browse/${JIRA_TICKET}" | |
| COMMENT="[${JIRA_TICKET}](${JIRA_LINK})" | |
| # Write comment on pull request | |
| curl -Ls \ | |
| -X POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| -H "Authorization: token ${GITHUB_TOKEN}" \ | |
| $CREATE_COMMENT_URL \ | |
| --data "$(generate_post_data)" 1>/dev/null | |
| printf '%s\n' 'Comment written!' | |
| fi |