From 5f3a8612ae705c220511ae97322dbbd92a635093 Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Tue, 26 Apr 2022 13:43:24 +0200 Subject: [PATCH] get rid of workflow, use pre-commit hook instead --- .github/workflows/main.yml | 36 ----------------------------------- data/webmentions.json | 14 ++++++++++++++ hooks/postdeploy.js | 19 +++++++++++++++++++ hooks/precommit.js | 39 ++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 5 files changed, 74 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 hooks/postdeploy.js create mode 100644 hooks/precommit.js diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 0e2142d..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -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 diff --git a/data/webmentions.json b/data/webmentions.json index 1b3d268..04f65d7 100644 --- a/data/webmentions.json +++ b/data/webmentions.json @@ -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—that’s 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 aren’t 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", diff --git a/hooks/postdeploy.js b/hooks/postdeploy.js new file mode 100644 index 0000000..6cfe807 --- /dev/null +++ b/hooks/postdeploy.js @@ -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!") +})() diff --git a/hooks/precommit.js b/hooks/precommit.js new file mode 100644 index 0000000..4caaa4b --- /dev/null +++ b/hooks/precommit.js @@ -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!") +})() diff --git a/package.json b/package.json index 073e446..4e54eb4 100644 --- a/package.json +++ b/package.json @@ -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",