-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
88 additions
and
2 deletions.
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,51 @@ | ||
name: cache EOL data | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# https://crontab.guru/#55_11,23_*_*_* | ||
- cron: '55 11,23 * * *' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
cache: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: step-security/harden-runner@v1 | ||
with: | ||
egress-policy: block | ||
allowed-endpoints: > | ||
github.com:443 | ||
nodejs.org:443 | ||
prod.api.stepsecurity.io:443 | ||
registry.npmjs.org:443 | ||
endoflife.date:443 | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: ljharb/actions/node/install@main | ||
|
||
- run: node cacheCycles.mjs | ||
|
||
- run: git checkout data | ||
|
||
- run: git add -f out | ||
|
||
- run: git mv -f out/* ./ | ||
|
||
- name: GIT commit and push all changed files | ||
env: | ||
CI_COMMIT_MESSAGE: '[cron] update data' | ||
CI_COMMIT_AUTHOR: Github Actions | ||
CI_COMMIT_EMAIL: [email protected] | ||
run: | | ||
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" | ||
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}" | ||
git commit -a -m "${{ env.CI_COMMIT_MESSAGE }}" | ||
git push |
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 |
---|---|---|
|
@@ -128,3 +128,6 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# data output | ||
out/ |
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,13 @@ | ||
import { mkdir, writeFile } from 'fs/promises'; | ||
import { join } from 'path'; | ||
|
||
import getCycles from './getCycles.mjs'; | ||
|
||
const cycles = await getCycles(); | ||
|
||
const outDir = join(process.cwd(), 'out'); | ||
const outFile = join(outDir, 'data.json'); | ||
|
||
await mkdir(outDir, { recursive: true }); | ||
|
||
await writeFile(outFile, JSON.stringify(cycles, null, '\t')); |
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,14 @@ | ||
import getProducts from "./getProducts.mjs"; | ||
|
||
export default async function getCycles() { | ||
const products = await getProducts(); | ||
|
||
return Object.fromEntries( | ||
await Promise.all( | ||
products.map(async (product) => [ | ||
product, | ||
await fetch(`https://endoflife.date/api/${product}.json`).then(x => x.json()) | ||
]), | ||
), | ||
); | ||
}; |
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,3 @@ | ||
export default function getProjects() { | ||
return fetch('https://endoflife.date/api/all.json').then(x => x.json()); | ||
}; |
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