Skip to content

Commit dcf36c2

Browse files
authored
Merge pull request #1392 from OneSignal/fg/fix-release
fix create release on github permissions
2 parents a23b672 + 1676d5d commit dcf36c2

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

.github/workflows/cd.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ on:
1111
jobs:
1212
check_release:
1313
runs-on: ubuntu-22.04
14+
outputs:
15+
should_run: ${{ steps.check.outputs.should_run }}
1416
steps:
1517
- name: Check if release merge or workflow dispatch
16-
id: check_release
18+
id: check
1719
uses: actions/github-script@v8
1820
with:
1921
script: |
20-
// Allow workflow_dispatch and release PR merges
21-
if (context.eventName !== 'push') return;
22-
23-
// For push events, check if it's a release merge
24-
const isReleaseMerge = /Release \d{6}/.test(context.payload.head_commit.message);
25-
if (!isReleaseMerge) core.setFailed('Not a release merge - skipping workflow');
22+
const shouldRun = context.eventName === 'workflow_dispatch' ||
23+
/Release \d{6}/.test(context.payload.head_commit.message);
24+
core.setOutput('should_run', shouldRun);
2625
2726
test_build_deploy:
2827
runs-on: ubuntu-22.04
2928
needs: check_release
29+
if: needs.check_release.outputs.should_run == 'true'
3030
steps:
3131
- uses: actions/checkout@v5
3232
- name: Use Node.js

.github/workflows/create-release-on-github.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ jobs:
77
create-release-notes:
88
runs-on: ubuntu-latest
99

10-
env:
11-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12-
1310
steps:
1411
- uses: actions/checkout@v5
1512
with:
@@ -59,17 +56,23 @@ jobs:
5956
return;
6057
}
6158
62-
core.setOutput('notes', releasePr.body);
59+
const releaseNotes = releasePr.body.split('<!--')[0].trim();
60+
core.setOutput('notes', releaseNotes);
61+
6362
- name: Create GitHub Release
6463
uses: actions/github-script@v8
64+
env:
65+
RELEASE_NOTES: ${{ steps.release_notes.outputs.notes }}
6566
with:
6667
script: |
68+
const notes = process.env.RELEASE_NOTES;
69+
6770
await github.rest.repos.createRelease({
6871
owner: context.repo.owner,
6972
repo: context.repo.repo,
7073
tag_name: '${{ steps.get_version.outputs.version }}',
7174
name: 'Release ${{ steps.get_version.outputs.version }}',
72-
body: '${{ steps.release_notes.outputs.notes }}',
75+
body: notes,
7376
draft: false,
7477
prerelease: false
7578
});

.github/workflows/create-release-pr.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ jobs:
103103
uses: actions/github-script@v8
104104
with:
105105
script: |
106-
const prs = JSON.parse('${{ steps.get_prs.outputs.prs }}');
106+
// Trim whitespace from PR titles
107+
const prs = JSON.parse('${{ steps.get_prs.outputs.prs }}').map(pr => ({
108+
...pr,
109+
title: pr.title.trim()
110+
}));
107111
108112
// Categorize PRs
109113
const features = prs.filter(pr => /^feat/i.test(pr.title));

0 commit comments

Comments
 (0)