From 23959c96bcdf81618cb7e5fd61e49d490d394353 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 21 Sep 2023 15:53:34 +1000 Subject: [PATCH] Send a Slack notification when api-changes PRs are merged --- .github/workflows/api-changes.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/api-changes.yml diff --git a/.github/workflows/api-changes.yml b/.github/workflows/api-changes.yml new file mode 100644 index 0000000000..669c6a1144 --- /dev/null +++ b/.github/workflows/api-changes.yml @@ -0,0 +1,33 @@ +name: Notify when API changes are merged + +on: + pull_request: + branches: [ "master" ] + types: + - closed + +jobs: + if_merged: + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'api changes') + runs-on: ubuntu-latest + steps: + - run: | + echo The PR was merged + - name: Send Slack notification + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + uses: 8398a7/action-slack@v3 + with: + status: custom + fields: repo,commit,event,action,workflow,ref,url + custom_payload: | + { + "attachments": [ + { + "color": "${{ job.status }}", + "title": "${{ github.actor }} ${{ github.event.pull_request && github.event.pull_request.merged == true && 'merged a pull request' || github.event.pull_request && 'opened a pull request' || github.event_name == 'push' && 'pushed new changes' || github.event_name == 'create' && 'created a new branch or tag' || github.event_name == 'delete' && 'deleted a branch or tag' || github.event_name == 'issues' && github.event.action || 'triggered an event' }}", + "text": ":tada: Event details:\n\n- Repository: ${{ github.repository }}\n- Branch: ${{ github.ref }}\n- Message: ${{ github.event_name == 'push' && github.event.head_commit.message || github.event_name == 'issues' && github.event.issue.title || github.event_name == 'pull_request' && github.event.pull_request.title || '' }}\n- :globe_with_meridians: Link: ${{ github.event.pull_request.html_url || github.event.issue.html_url || github.event.repository.html_url }}" + } + + ] + }