feat(postcodes/VI): 6 USVI ZIPs (#1039) #143
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 Merge Notification | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [master, main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| notify: | |
| name: Notify on merge | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.merged == true | |
| steps: | |
| - name: Slack notification | |
| uses: actions/github-script@v7 | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| with: | |
| script: | | |
| const webhookUrl = process.env.SLACK_WEBHOOK_URL; | |
| if (!webhookUrl) return; | |
| const https = require('https'); | |
| const pr = context.payload.pull_request; | |
| const payload = { | |
| attachments: [{ | |
| color: '#36A64F', | |
| blocks: [ | |
| { | |
| type: 'header', | |
| text: { type: 'plain_text', text: ':white_check_mark: PR Merged', emoji: true }, | |
| }, | |
| { | |
| type: 'section', | |
| fields: [ | |
| { type: 'mrkdwn', text: `*PR:* <${pr.html_url}|#${pr.number}> ${pr.title}` }, | |
| { type: 'mrkdwn', text: `*Author:* @${pr.user.login}` }, | |
| ], | |
| }, | |
| ], | |
| }], | |
| }; | |
| const url = new URL(webhookUrl); | |
| const data = JSON.stringify(payload); | |
| await new Promise((resolve) => { | |
| const req = https.request({ | |
| hostname: url.hostname, | |
| path: url.pathname, | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) }, | |
| }, (res) => { | |
| if (res.statusCode !== 200) core.warning(`Slack responded with ${res.statusCode}`); | |
| resolve(); | |
| }); | |
| req.on('error', (err) => { | |
| core.warning(`Slack error: ${err.message}`); | |
| resolve(); | |
| }); | |
| req.write(data); | |
| req.end(); | |
| }); |