From e9707c060caed1e1e227c3f039653d15c4a2287d Mon Sep 17 00:00:00 2001 From: Balrambhai Sharma Date: Tue, 26 Sep 2023 17:53:22 +0530 Subject: [PATCH] =?UTF-8?q?TP-42918=20|=20UITron=20|=20Streamline=20PR=20R?= =?UTF-8?q?eviews=20with=20Automated=20Slack=20Notifi=E2=80=A6=20(#189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit link: https://github.com/navi-android/uitron/pull/189 --- .github/workflows/pr_review.yml | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/pr_review.yml diff --git a/.github/workflows/pr_review.yml b/.github/workflows/pr_review.yml new file mode 100644 index 0000000..27acb03 --- /dev/null +++ b/.github/workflows/pr_review.yml @@ -0,0 +1,37 @@ +name: Label Triggered Workflow + +on: + pull_request: + types: + - labeled + +jobs: + label_triggered_job: + runs-on: [ default ] + steps: + - name: Check label and send Slack message + id: check_label_and_send_slack + run: | + if [ "${{ github.event.label.name }}" == "Ready For Review" ]; then + PR_URL="${{ github.event.pull_request.html_url }}" + PR_TITLE="${{ github.event.pull_request.title }}" + PR_BODY="${{ github.event.pull_request.body }}" + PR_AUTHOR="${{ github.event.pull_request.user.login }}" + + MESSAGE=" Please review this PR" + + # Define an array of attachments + ATTACHMENTS="[{ + \"title\": \"$PR_TITLE\", + \"text\": \"$PR_BODY\", + \"author_name\": \"$PR_AUTHOR\", + \"title_link\": \"$PR_URL\" + }]" + + JSON_PAYLOAD="{\"text\":\"$MESSAGE\",\"attachments\":$ATTACHMENTS}" + + # Send the message with the attachment + curl -X POST -H 'Content-type: application/json' --data "$JSON_PAYLOAD" "${{ secrets.SLACK_PR_STATUS_HOOK }}" + else + echo "Label is not Ready For Review. Skipping Slack notification." + fi \ No newline at end of file