Skip to content

feat(postcodes/NA): 149 NamPost postcodes β€” all 14 regions (#1039) #163

feat(postcodes/NA): 149 NamPost postcodes β€” all 14 regions (#1039)

feat(postcodes/NA): 149 NamPost postcodes β€” all 14 regions (#1039) #163

Workflow file for this run

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();
});