Skip to content

build

build #96

Workflow file for this run

name: build
on:
push:
schedule:
#- cron: '0 * * * *' # hourly.
- cron: '0 0 * * WED' # every wednesday.
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Build
run: node main.js
- name: Build summary
shell: pwsh
run: |
Get-ChildItem data/*.json | ForEach-Object {
Add-Content $env:GITHUB_STEP_SUMMARY @"
# $(Split-Path -Leaf $_)
| Date | Name |
| :--- | :--- |
"@
Get-Content -Raw $_ | ConvertFrom-Json | ForEach-Object {
Add-Content $env:GITHUB_STEP_SUMMARY @"
| $($_.date.ToString('O') -replace 'T.+','') | [$($_.name -replace '\|','\|')]($($_.url)) |
"@
}
}
- name: Upload artifacts
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: artifacts
path: |
data/*.json
*.png
commit:
if: github.event.schedule
name: Commit
runs-on: ubuntu-22.04
needs:
- build
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Commit data
shell: bash
run: |
set -euxo pipefail
rm data/*.json
mv artifacts/data/*.json data
rm -rf artifacts
if [ -n "$(git status -s data)" ]; then
git config user.name 'Bot'
git config user.email 'bot@localhost'
echo 'Committing data...'
git add data
git diff --staged
git commit -m 'update data'
git push
fi