Skip to content

Commit b6094da

Browse files
committed
chore(release-blogs): fix a few issues
1 parent ad86795 commit b6094da

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ jobs:
3333
use-version-file: true
3434

3535
- run: node --run scripts:release-post "$VERSION"
36+
working-directory: apps/site
3637
env:
3738
VERSION: ${{ inputs.version }}
3839

3940
- name: Open pull request
4041
uses: gr2m/create-or-update-pull-request-action@b65137ca591da0b9f43bad7b24df13050ea45d1b # v1.10.1
4142
# Creates a PR or update the Action's existing PR, or
4243
# no-op if the base branch is already up-to-date.
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4346
with:
4447
update-pull-request-title-and-body: true
4548
branch: release-${{ inputs.version }}

apps/site/scripts/release-post/index.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import { existsSync, readFileSync } from 'node:fs';
2424
import { writeFile } from 'node:fs/promises';
2525
import { resolve } from 'node:path';
26+
import { parseArgs } from 'node:util';
2627

2728
import handlebars from 'handlebars';
2829
import { format } from 'prettier';
@@ -58,10 +59,20 @@ const ERRORS = {
5859
new Error(`Failed to write Release post: Reason: ${reason}`),
5960
};
6061

62+
const parsedArgs = parseArgs({
63+
options: {
64+
force: {
65+
type: 'boolean',
66+
short: 'f',
67+
},
68+
},
69+
allowPositionals: true,
70+
});
71+
6172
const ARGS = {
6273
CURRENT_PATH: process.argv[1],
63-
SPECIFIC_VERSION: process.argv[2] && process.argv[2].replace('--force', ''),
64-
SHOULD_FORCE: (process.argv[3] || process.argv[2]) === '--force',
74+
SPECIFIC_VERSION: parsedArgs.positionals[0]?.replace(/^v/, ''),
75+
SHOULD_FORCE: Boolean(parsedArgs.values.force),
6576
};
6677

6778
// this allows us to get the current module working directory
@@ -262,9 +273,6 @@ if (import.meta.url.startsWith('file:')) {
262273
.then(renderPost)
263274
.then(formatPost)
264275
.then(writeToFile)
265-
.then(
266-
filepath => console.log('Release post created:', filepath),
267-
error => console.error('Some error occurred here!', error.stack)
268-
);
276+
.then(filepath => console.log('Release post created:', filepath));
269277
}
270278
}

0 commit comments

Comments
 (0)