-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automated job to create es yearly globals (#257)
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Create ES yearly globals | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# “At 00:00 on day-of-month 1 in July.” https://crontab.guru/#0_0_1_7_* | ||
- cron: "0 0 1 7 *" | ||
|
||
jobs: | ||
update: | ||
if: github.event_name != 'schedule' || github.repository == 'sindresorhus/globals' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
- run: npm install | ||
- run: node scripts/create-yearly-es-globals.mjs | ||
- run: npm run build | ||
- uses: peter-evans/create-pull-request@v6 | ||
with: | ||
commit-message: Add `es2026` globals | ||
branch: automated-es-yearly-globals | ||
branch-suffix: timestamp | ||
title: Add `es2026` globals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import fs from 'node:fs'; | ||
|
||
const year = new Date().getFullYear(); | ||
const dataFile = new URL(`../data/es${year + 1}.mjs`, import.meta.url); | ||
const workflowFile = new URL('../.github/workflows/es-yearly-globals.yml', import.meta.url); | ||
|
||
fs.writeFileSync( | ||
dataFile, | ||
`export {default} from './es${year}.mjs';\n`, | ||
); | ||
|
||
fs.writeFileSync( | ||
workflowFile, | ||
fs.readFileSync(workflowFile, 'utf8') | ||
.replaceAll( | ||
`Add \`es${year + 1}\` globals`, | ||
`Add \`es${year + 2}\` globals`, | ||
), | ||
); | ||
|
||
console.log(`✅ es${year + 1} globals added, see you next year.`); |