forked from elastic/terraform-provider-elasticstack
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (43 loc) · 1.54 KB
/
Copy pathgenerate-release-notes.yml
File metadata and controls
52 lines (43 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Generate release notes
on:
release:
types: [published]
permissions:
contents: write
pull-requests: read
jobs:
generate:
name: Generate and set release notes
runs-on: ubuntu-latest
steps:
- name: Generate notes and update release
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const marker = '<!-- autogenerated-release-notes -->';
const owner = context.repo.owner;
const repo = context.repo.repo;
const release = context.payload.release;
const releaseId = release.id;
const tagName = release.tag_name;
const existingBody = release.body || '';
const shouldUpdate =
existingBody.trim() === '' || existingBody.includes(marker);
if (!shouldUpdate) {
core.info('Release body is non-empty and not marked as autogenerated. Skipping update.');
return;
}
core.info(`Generating release notes for tag ${tagName}`);
const generated = await github.rest.repos.generateReleaseNotes({
owner,
repo,
tag_name: tagName,
});
const newBody = `${marker}\n\n${generated.data.body || ''}`.trim() + '\n';
core.info(`Updating release ${releaseId}`);
await github.rest.repos.updateRelease({
owner,
repo,
release_id: releaseId,
body: newBody,
});