Test Qlty coverage upload #2
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: Notify Mattermost on merged PRs | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [master] | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| notify: | |
| if: github.event.pull_request.merged == true && | |
| ( | |
| github.event.pull_request.user.login == 'renovate[bot]' || | |
| github.event.pull_request.user.login == 'dependabot[bot]' || | |
| github.event.pull_request.user.login == 'snyk-bot' | |
| ) && | |
| ( | |
| github.event.pull_request.merged_by.login == 'github-actions[bot]' || | |
| github.event.pull_request.merged_by.login == 'renovate[bot]' | |
| ) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send Mattermost notification | |
| env: | |
| MATTERMOST_BOT_TOKEN: ${{ secrets.MATTERMOST_BOT_TOKEN }} | |
| MATTERMOST_CHANNEL_ID: ${{ secrets.MATTERMOST_CHANNEL_ID }} | |
| MATTERMOST_BASE_URL: ${{ secrets.MATTERMOST_BASE_URL }} | |
| REPO: ${{ github.repository }} | |
| ACTOR: ${{ github.event.pull_request.merged_by.login }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| MERGED_AT: ${{ github.event.pull_request.merged_at }} | |
| run: | | |
| if [ -z "$MATTERMOST_BOT_TOKEN" ] || [ -z "$MATTERMOST_CHANNEL_ID" ] || [ -z "$MATTERMOST_BASE_URL" ]; then | |
| echo "Missing Mattermost secrets (MATTERMOST_BOT_TOKEN, MATTERMOST_CHANNEL_ID, MATTERMOST_BASE_URL)" >&2 | |
| exit 1 | |
| fi | |
| curl -sS -X POST \ | |
| -H "Authorization: Bearer $MATTERMOST_BOT_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"channel_id\":\"$MATTERMOST_CHANNEL_ID\",\"message\":\"[$REPO] PR #$PR_NUMBER: \\\"$PR_TITLE\\\" was merged by $ACTOR.\\nMerged at: $MERGED_AT\\nLink: $PR_URL\"}" \ | |
| "$MATTERMOST_BASE_URL/api/v4/posts" |