Skip to content

Commit df410c8

Browse files
authoredJul 3, 2024
Add automated job to create es yearly globals (#257)
1 parent f6b3978 commit df410c8

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed
 
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Create ES yearly globals
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# “At 00:00 on day-of-month 1 in July.” https://crontab.guru/#0_0_1_7_*
7+
- cron: "0 0 1 7 *"
8+
9+
jobs:
10+
update:
11+
if: github.event_name != 'schedule' || github.repository == 'sindresorhus/globals'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
- run: npm install
17+
- run: node scripts/create-yearly-es-globals.mjs
18+
- run: npm run build
19+
- uses: peter-evans/create-pull-request@v6
20+
with:
21+
commit-message: Add `es2026` globals
22+
branch: automated-es-yearly-globals
23+
branch-suffix: timestamp
24+
title: Add `es2026` globals

‎.github/workflows/update.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- run: npm run update
2121
- uses: peter-evans/create-pull-request@v6
2222
with:
23-
commit-message: Update
23+
commit-message: Update globals
2424
branch: automated-update
2525
branch-suffix: timestamp
2626
title: Update globals

‎scripts/create-yearly-es-globals.mjs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import fs from 'node:fs';
2+
3+
const year = new Date().getFullYear();
4+
const dataFile = new URL(`../data/es${year + 1}.mjs`, import.meta.url);
5+
const workflowFile = new URL('../.github/workflows/es-yearly-globals.yml', import.meta.url);
6+
7+
fs.writeFileSync(
8+
dataFile,
9+
`export {default} from './es${year}.mjs';\n`,
10+
);
11+
12+
fs.writeFileSync(
13+
workflowFile,
14+
fs.readFileSync(workflowFile, 'utf8')
15+
.replaceAll(
16+
`Add \`es${year + 1}\` globals`,
17+
`Add \`es${year + 2}\` globals`,
18+
),
19+
);
20+
21+
console.log(`✅ es${year + 1} globals added, see you next year.`);

0 commit comments

Comments
 (0)