Skip to content

Bump the types group across 1 directory with 2 updates #1785

Bump the types group across 1 directory with 2 updates

Bump the types group across 1 directory with 2 updates #1785

Workflow file for this run

name: Post PR to Slack
on:
pull_request:
types:
- opened
- converted_to_draft
- ready_for_review
- reopened
- closed
pull_request_review:
types:
- submitted
env:
CONFIG: |
{
"opened": {
"icon": "${{ github.event.pull_request.draft && 'πŸ“' || 'πŸ†•' }}",
"status": "${{ github.event.pull_request.draft && 'opened as draft' || 'opened' }}"
},
"converted_to_draft": {
"icon": "πŸ“",
"status": "converted to draft"
},
"ready_for_review": {
"icon": "πŸ‘€",
"status": "ready for review"
},
"reopened": {
"icon": "πŸ”„",
"status": "reopened"
},
"submitted": {
"icon": "${{ github.event.review.state == 'approved' && 'βœ…' || 'πŸ’¬' }}",
"status": "${{ github.event.review.state == 'approved' && 'code review approved' || 'code review comments' }}"
},
"closed": {
"icon": "${{ github.event.pull_request.merged && 'πŸš€' || 'πŸ—‘οΈ' }}",
"status": "${{ github.event.pull_request.merged && 'merged' || 'closed' }}"
}
}
jobs:
notify:
name: Slack notify
runs-on: ubuntu-latest
if: ${{ !contains(github.head_ref || github.ref, 'dependabot/') }}
steps:
- name: Build Slack JSON
uses: actions/github-script@v7.0.1
id: payload
if: github.event.action != 'submitted' || github.event.review.state == 'approved'
env:
ACTION_ICON: ${{ fromJSON(env.CONFIG)[github.event.action].icon }}
ACTION_STATUS: ${{ fromJSON(env.CONFIG)[github.event.action].status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const title = ${{ toJson(github.event.pull_request.title) }}
const username = ${{ toJson(github.event.pull_request.user.login) }}
const profileUrl = ${{ toJson(github.event.pull_request.user.html_url) }}
const { pull_request } = context.payload
const { owner, repo } = context.repo
// Format as Slack mrkdwn
const titleFormatted = `<${pull_request.html_url}|*${title}* #${pull_request.number}>`
const profileFormatted = `<${profileUrl}|@${username}>`
// Payload output is JSON encoded
return {
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: `${owner}/*${repo}*: ${titleFormatted} byΒ ${profileFormatted} ${{ env.ACTION_ICON }}Β ${{ env.ACTION_STATUS }}`
}
}
],
unfurl_links: false,
unfurl_media: false
}
- name: Post to Slack
uses: slackapi/slack-github-action@v1.27.0
if: github.event.action != 'submitted' || github.event.review.state == 'approved'
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: ${{ vars.SLACK_CHANNEL_ID }}
payload: ${{ steps.payload.outputs.result }}