Generate Dashboard #327
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
name: Generate Dashboard | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "36 0 * * *" | |
workflow_dispatch: | |
env: | |
DB_FILENAME: dashboard.db | |
B2_APPLICATION_KEY_ID: ${{ secrets.B2_APPLICATION_KEY_ID }} | |
B2_APPLICATION_KEY: ${{ secrets.B2_APPLICATION_KEY }} | |
B2_BUCKET_ID: ${{ secrets.B2_BUCKET_ID }} | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
container: alpine:latest | |
permissions: | |
id-token: write | |
pages: write | |
steps: | |
- name: update package index | |
run: apk -q update | |
- name: install packages | |
run: | | |
apk -q add \ | |
git \ | |
nodejs \ | |
curl \ | |
jq \ | |
jo \ | |
gcc \ | |
make \ | |
tar \ | |
idn2-utils \ | |
perl-app-cpanminus \ | |
perl-class-accessor \ | |
perl-class-accessor-chained \ | |
perl-class-method-modifiers \ | |
perl-datetime-format-iso8601 \ | |
perl-dbd-sqlite \ | |
perl-extutils-config \ | |
perl-file-slurp \ | |
perl-json \ | |
perl-json-xs \ | |
perl-list-moreutils \ | |
perl-lwp-protocol-https \ | |
perl-mime-charset \ | |
perl-mime-types \ | |
perl-module-build \ | |
perl-moo \ | |
perl-net-dns-sec \ | |
perl-net-ip \ | |
perl-path-tiny \ | |
perl-test-exception \ | |
perl-test-most \ | |
perl-text-csv_xs \ | |
perl-text-vfile-asdata \ | |
perl-unicode-linebreak \ | |
perl-xml-libxml \ | |
perl-yaml-libyaml | |
- name: install perl modules | |
run: | | |
cpanm -qn \ | |
Data::Mirror \ | |
HTML::Tiny \ | |
Net::RDAP \ | |
Number::Format \ | |
Object::Anon \ | |
Template::Liquid | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: authenticate with b2 | |
run: | | |
curl --silent --fail --basic \ | |
--user "$B2_APPLICATION_KEY_ID:$B2_APPLICATION_KEY" \ | |
--output b2.json \ | |
https://api.backblazeb2.com/b2api/v3/b2_authorize_account | |
- name: download database | |
run: | | |
curl --silent --fail \ | |
--header "Authorization: $(jq -r .authorizationToken b2.json)" \ | |
--output "$DB_FILENAME" \ | |
"$(jq -r .apiInfo.storageApi.downloadUrl b2.json)/file/rdap-deployment/$DB_FILENAME" \ | |
|| true | |
- name: create site directory | |
run: | | |
mkdir -v _site | |
- name: copy assets | |
run: | | |
cp -Rv assets _site/ | |
- name: generate dashboard | |
run: | | |
./deployment.pl "$DB_FILENAME" > _site/index.html | |
- name: generate RSS feed | |
run: | | |
./rss.pl "$DB_FILENAME" > _site/rss.xml | |
- name: upload database | |
run: | | |
curl --silent --fail \ | |
--header "Authorization: $(jq -r .authorizationToken b2.json)" \ | |
--output upload.json \ | |
--data "$(jo bucketId=$B2_BUCKET_ID)" \ | |
"$(jq -r .apiInfo.storageApi.apiUrl b2.json)/b2api/v3/b2_get_upload_url" | |
curl --silent --fail \ | |
--header "Authorization: $(jq -r .authorizationToken upload.json)" \ | |
--header "Content-Type: application/octet-stream" \ | |
--header "Content-Length: $(wc -c "$DB_FILENAME" | cut -d " " -f 1)" \ | |
--header "X-Bz-File-Name: $DB_FILENAME" \ | |
--header "X-Bz-Content-Sha1: $(sha1sum -b "$DB_FILENAME" | cut -d " " -f 1)" \ | |
--data-binary "@$DB_FILENAME" \ | |
--output /dev/null \ | |
"$(jq -r .uploadUrl upload.json)" | |
- name: clean up | |
run: rm -f b2.json upload.json | |
- name: configure | |
uses: actions/configure-pages@v4 | |
- name: upload | |
uses: actions/upload-pages-artifact@v3 | |
- name: deploy | |
uses: actions/deploy-pages@v4 |