mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig.space.git
synced 2025-12-13 16:26:50 +00:00
🛠 Content updates and build trigger
This commit is contained in:
30
tasks/check-feed.sh
Executable file
30
tasks/check-feed.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
dir=$(dirname "$0")
|
||||
log="$dir/check-feed.log"
|
||||
file="$dir/.check-feed"
|
||||
prev=$(cat $file)
|
||||
feed=$(curl -s https://anchor.fm/s/d8d3c38/podcast/rss)
|
||||
date=$(echo "$feed" | awk 'BEGIN { FS="<|>"; RS="\n" }; { if ($0 ~ /lastBuildDate/) print $3}')
|
||||
|
||||
if [[ ! -z "$date" ]]; then
|
||||
echo "Latest build: $prev"
|
||||
echo "Last updated: $date"
|
||||
|
||||
if [[ "$date" != "$prev" ]]; then
|
||||
if [[ ! -z "$GH_PAT" ]]; then
|
||||
echo "-> Triggering new build"
|
||||
curl -X POST https://api.github.com/repos/Einundzwanzig-Podcast/einundzwanzig.space/dispatches \
|
||||
-H "Authorization: token $GH_PAT" \
|
||||
-H "Accept: application/vnd.github.everest-preview+json" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"event_type": "anchor_update"}'
|
||||
|
||||
echo $date >> $log
|
||||
else
|
||||
echo "Missing GH_PAT environment variable!"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $date > $file
|
||||
fi
|
||||
@@ -1,12 +1,22 @@
|
||||
const { writeFileSync } = require('fs')
|
||||
const { join, resolve } = require('path')
|
||||
const request = require('sync-request')
|
||||
|
||||
const meta = require('../content/meta.json')
|
||||
|
||||
const dir = resolve(__dirname, '..', 'generated')
|
||||
const dst = join(dir, 'site-data.json')
|
||||
|
||||
let recentBlocks = []
|
||||
try {
|
||||
const jsonBody = request('GET', 'https://mempool.observer/api/recentBlocks').getBody('utf8')
|
||||
recentBlocks = JSON.parse(jsonBody)
|
||||
} catch (err) {
|
||||
console.error('Could not load recent blocks:', err)
|
||||
}
|
||||
|
||||
const block = recentBlocks.length && recentBlocks[0].height
|
||||
const date = (new Date()).toJSON().split('T')[0]
|
||||
const data = { date, meta }
|
||||
const data = { date, block, meta }
|
||||
|
||||
writeFileSync(dst, JSON.stringify(data, null, 2))
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
const compress_images = require('compress-images')
|
||||
const input = 'compress/*.{jpg,png,svg,gif}'
|
||||
const output = 'compress/out/'
|
||||
|
||||
compress_images(input, output, { compress_force: true, statistic: true, autoupdate: false }, false,
|
||||
{ jpg: { engine: "mozjpeg", command: ["-quality", "60"] } },
|
||||
{ png: { engine: "pngquant", command: ["--quality=20-50", "-o"] } },
|
||||
{ svg: { engine: "svgo", command: "--multipass" } },
|
||||
{ gif: { engine: "gifsicle", command: ["--colors", "64", "--use-col=web"] } },
|
||||
(error, completed, statistic) => {
|
||||
if (error) console.error(error)
|
||||
if (statistic) console.log(statistic)
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user