get rid of workflow, use pre-commit hook instead

This commit is contained in:
Wouter Groeneveld 2022-04-26 13:43:24 +02:00
parent 874b187471
commit 5f3a8612ae
5 changed files with 74 additions and 37 deletions

View File

@ -1,36 +0,0 @@
name: CI
on:
push:
branches: [ master ]
env:
WEBMENTION_TOKEN: ${{secrets.WEBMENTION_TOKEN}}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn jamstack build
run: |
yarn install
yarn run jamstack
- name: commit generated hugo stuff
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: jamstack update metadata

View File

@ -1,4 +1,18 @@
[
{
"author": {
"name": "Jefklak",
"picture": "/pictures/jefklakscodex.com"
},
"name": "Looney Tunes Racing: Not So Daffy After All",
"content": "Not every Looney game is a Tune—thats what I learned from playing this 2D Mario Kart arcade racing clone on the Game Boy Color. The fact that it nowaday costs less than €5 should probably raise an alarm bell—if collectors arent after it, ...",
"published": "2022-04-25T00:00:00+00:00",
"url": "https://jefklakscodex.com/games/gameboycolor/looney-tunes-racing/",
"type": "mention",
"source": "https://jefklakscodex.com/games/gameboycolor/looney-tunes-racing/",
"target": "https://jefklakscodex.com/games/gameboycolor",
"relativeTarget": "/games/gameboycolor"
},
{
"author": {
"name": "Wouter Groeneveld",

19
hooks/postdeploy.js Normal file
View File

@ -0,0 +1,19 @@
const { webmention } = require('jam-my-stack');
if(!process.env.WEBMENTION_TOKEN) {
throw "No webmention token set!"
}
const wmconfig = {
endpoint: 'https://jam.brainbaking.com',
token: process.env.WEBMENTION_TOKEN
};
(async function() {
// 1. send webmentions
console.log("1. Sending webmentions...")
await webmention.send("jefklakscodex.com", wmconfig)
console.log("-- all done!")
})()

39
hooks/precommit.js Normal file
View File

@ -0,0 +1,39 @@
const { howlongtobeat, webmention, youtube } = require('jam-my-stack');
const fsp = require('fs').promises;
if(!process.env.WEBMENTION_TOKEN) {
throw "No webmention token set!"
}
const wmconfig = {
endpoint: 'https://jam.brainbaking.com',
token: process.env.WEBMENTION_TOKEN
};
const rootdir = `${__dirname}/../`;
(async function() {
// 1. get how long to beat times
console.log("1. adding Howlongtobeat info...")
await howlongtobeat.howlong({
postDir: `${rootdir}/content`,
downloadDir: `${rootdir}/static/img/hltb`
})
// 2. get webmentions
console.log("2. Fetching webmentions...")
const mentions = await webmention.getWebmentions("jefklakscodex.com", wmconfig)
const json = JSON.stringify(mentions, null, 4)
await fsp.writeFile(`${rootdir}/data/webmentions.json`, json, 'utf-8')
// 3. generate youtube thumbnails.
console.log("4. Generating YouTube thumbnails...")
await youtube.thumbify({
postDir: `${rootdir}/content`,
downloadDir: `${rootdir}/static/img/yt`,
overlayImg: `${rootdir}/play.png`
})
console.log("-- all done!")
})()

View File

@ -7,7 +7,8 @@
"doc": "docs"
},
"scripts": {
"jamstack": "node jamstack-init.js"
"precommit": "node hooks/precommit.js",
"postdeploy": "node hooks/postdeploy.js"
},
"repository": {
"type": "git",