-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
237a777
commit de2580d
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: PR Merge | ||
|
||
on: | ||
pull_request: | ||
types: [ closed ] | ||
|
||
jobs: | ||
notify: | ||
if: github.event.pull_request.merged == true && github.ref == 'refs/heads/production' | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Prepare Slack Message | ||
id: slack-body-formatter | ||
run: | | ||
SLACK_MESSAGE="${{github.event.pull_request.body}}" | ||
echo "::set-output name=slack-message::${SLACK_MESSAGE//$'\r\n'/'\n'}" | ||
- name: Send GitHub Action trigger data to Slack workflow | ||
id: slack | ||
uses: slackapi/slack-github-action@v1.24.0 | ||
with: | ||
# This data can be any valid JSON from a previous step in the GitHub Action | ||
payload: | | ||
{ | ||
"text": "${{ github.event.repository.name }} deployed by ${{ github.event.pull_request.user.login }}", | ||
"blocks": [ | ||
{ | ||
"type": "header", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "----------------------\n${{ github.event.repository.name }} Deployed\n----------------------\n${{ github.event.pull_request.title }}" | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "*Pull request created by ${{ github.event.pull_request.user.login }}*" | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "${{ steps.slack-body-formatter.outputs.slack-message }}" | ||
} | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |