mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 16:10:43 +00:00
66 lines
2.3 KiB
YAML
66 lines
2.3 KiB
YAML
name: Release Webhook Notification
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
jobs:
|
|
notify-webhook:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Send release notification to webhook
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const release = context.payload.release;
|
|
function cleanChangelog(changelog) {
|
|
if (!changelog) return '';
|
|
return changelog
|
|
.split(/\r?\n/)
|
|
.map(line => {
|
|
if (line.toLowerCase().includes('full changelog')) return '';
|
|
line = line.replace(/by\s+@[\w-]+.*$/i, '');
|
|
line = line.replace(/@\w+/g, '');
|
|
line = line.replace(/\bhttps?:\/\/\Spull\S/gi, '');
|
|
return line.trim();
|
|
})
|
|
.filter(line => line.length > 0)
|
|
.join('\n');
|
|
}
|
|
|
|
const cleanedBody = cleanChangelog(release.body);
|
|
const payload = {
|
|
version: release.tag_name,
|
|
release_name: release.name,
|
|
release_url: release.html_url,
|
|
changelog: cleanedBody || 'No release notes provided',
|
|
type: 'PUBLIC',
|
|
date: release.published_at
|
|
};
|
|
try {
|
|
const response = await fetch(`${process.env.STRAPI_WEBHOOK_URL}?status=draft`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Authorization': `Bearer ${process.env.STRAPI_API_TOKEN}`,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({data: payload})
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Webhook request failed: ${response.status} ${response.statusText}`);
|
|
}
|
|
|
|
console.log('Response status:', response.status);
|
|
} catch (error) {
|
|
console.error('Failed to send webhook notification:', error);
|
|
core.setFailed(error.message);
|
|
}
|
|
env:
|
|
STRAPI_WEBHOOK_URL: ${{ secrets.STRAPI_WEBHOOK_URL }}
|
|
STRAPI_API_TOKEN: ${{ secrets.STRAPI_API_TOKEN }} |