feat: add support for CRITERION_HOME #12846
Workflow file for this run
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: PR Slack Notification | |
| on: | |
| # pull_request_target needs to be used so that we can use the SLACK_API_TOKEN secret for forked PRs | |
| # however, pull_request_target cannot be used with a checkout step, which why we need to curl the team-channels.json file | |
| pull_request_target: | |
| types: [review_requested] | |
| jobs: | |
| notify-slack: | |
| name: Notify Slack | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Sanitize PR title for Slack (<, >, &) | |
| - name: Sanitize PR title | |
| if: github.event.pull_request.head.repo.full_name == github.repository # only for internal PRs | |
| id: sanitize | |
| env: | |
| RAW_TITLE: ${{ github.event.pull_request.title }} | |
| run: | | |
| ESCAPED_TITLE=$(echo "$RAW_TITLE" \ | |
| | sed 's/&/\&/g' \ | |
| | sed 's/</\</g' \ | |
| | sed 's/>/\>/g') | |
| echo "safe_title=$ESCAPED_TITLE" >> "$GITHUB_OUTPUT" | |
| - name: Get requested team reviewers | |
| id: get-reviewers | |
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| return "requested_team" in context.payload ? context.payload.requested_team.name : "" | |
| - name: Lookup Slack channel | |
| id: lookup | |
| if: steps.get-reviewers.outputs.result != '""' | |
| run: | | |
| TEAM=${{ steps.get-reviewers.outputs.result }} | |
| curl -sSL https://raw.githubusercontent.com/dfinity/ic/master/.github/workflows/team-channels.json -o team-channels.json | |
| CHANNEL=$(jq -r --arg team "$TEAM" '.[$team]' team-channels.json) | |
| echo "channel=${CHANNEL}" >> $GITHUB_OUTPUT | |
| echo "message=${MESSAGE}" >> $GITHUB_OUTPUT | |
| env: | |
| MESSAGE: ":github: ${{ github.event.pull_request.head.repo.full_name != github.repository && ':alert: EXTERNAL PR, review extra carefully! :alert: ' || '' }}`${{ github.repository }}` <${{ github.event.pull_request.html_url }}|${{ steps.sanitize.outputs.safe_title || '' }}>" | |
| - name: Post to a Slack channel | |
| if: steps.get-reviewers.outputs.result != '""' && steps.lookup.outputs.channel != 'null' | |
| id: slack | |
| uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0 | |
| with: | |
| channel-id: ${{ steps.lookup.outputs.channel }} | |
| slack-message: "${{ steps.lookup.outputs.message }}" | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN }} |