Wire Jumbo (lomi. Pos) into monorepo CI, audit, and docs #32
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: lomi · notify · slack · github | |
| on: | |
| issues: | |
| types: [opened] | |
| pull_request: | |
| types: [opened] | |
| workflow_dispatch: | |
| jobs: | |
| notify-devops: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Notify #devops on Slack | |
| uses: actions/github-script@v7 | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| with: | |
| script: | | |
| const webhook = process.env.SLACK_WEBHOOK_URL; | |
| if (!webhook) { | |
| core.info('SLACK_WEBHOOK_URL not set; skipping notification'); | |
| return; | |
| } | |
| let payload; | |
| if (context.eventName === 'workflow_dispatch') { | |
| payload = { | |
| blocks: [ | |
| { | |
| type: 'section', | |
| text: { | |
| type: 'mrkdwn', | |
| text: `:white_check_mark: *GitHub → Slack test* for \`${context.repo.owner}/${context.repo.repo}\`\nNotifications for new issues and pull requests will post to *#devops*.`, | |
| }, | |
| }, | |
| ], | |
| }; | |
| } else { | |
| const isIssue = context.eventName === 'issues'; | |
| const item = isIssue ? context.payload.issue : context.payload.pull_request; | |
| const kind = isIssue ? 'Issue' : 'Pull request'; | |
| const emoji = isIssue ? ':issue-opened:' : ':pull-request:'; | |
| payload = { | |
| blocks: [ | |
| { | |
| type: 'section', | |
| text: { | |
| type: 'mrkdwn', | |
| text: `${emoji} *New ${kind}* in \`${context.repo.owner}/${context.repo.repo}\`\n<${item.html_url}|${item.title}>\nOpened by *${item.user.login}*`, | |
| }, | |
| }, | |
| ], | |
| }; | |
| } | |
| const response = await fetch(webhook, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify(payload), | |
| }); | |
| const body = await response.text(); | |
| if (!response.ok) { | |
| core.setFailed(`Slack webhook failed (${response.status}): ${body}`); | |
| return; | |
| } | |
| core.info('Posted notification to #devops'); |