get rid of workflow, use pre-commit hook instead

This commit is contained in:
Wouter Groeneveld 2022-04-26 13:46:50 +02:00
parent 29502fb247
commit 0f9b3999b3
4 changed files with 33 additions and 51 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

20
hooks/postdeploy.js Normal file
View File

@ -0,0 +1,20 @@
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...")
const since = await webmention.send("redzuurdesem.be", wmconfig)
console.log(` -- done`)
console.log("-- all done!")
})()

View File

@ -11,32 +11,29 @@ const wmconfig = {
token: process.env.WEBMENTION_TOKEN
};
const rootdir = `${__dirname}/../`;
(async function() {
// 1. build Lunr index
console.log("1. Building lunr search index...")
const index = await lunr.buildIndex([
`${__dirname}/content/post`,
`${__dirname}/content/kort`,
`${__dirname}/content/leren`])
await fsp.writeFile(`${__dirname}/static/js/redzuurdesem-post.json`, JSON.stringify(index), 'utf-8')
`${rootdir}/content/post`,
`${rootdir}/content/kort`,
`${rootdir}/content/leren`])
await fsp.writeFile(`${rootdir}/static/js/redzuurdesem-post.json`, JSON.stringify(index), 'utf-8')
// 2. get webmentions
console.log("2. Fetching webmentions...")
const mentions = await webmention.getWebmentions("redzuurdesem.be", wmconfig)
const json = JSON.stringify(mentions, null, 4)
await fsp.writeFile(`${__dirname}/data/webmentions.json`, json, 'utf-8')
await fsp.writeFile(`${rootdir}/data/webmentions.json`, json, 'utf-8')
// 3. send webmentions
console.log("3. Sending webmentions...")
const since = await webmention.send("redzuurdesem.be", wmconfig)
console.log(` -- done`)
// 4. build youtube thumbnails
// 3. build youtube thumbnails
console.log("4. building youtube thumbnails...")
await youtube.thumbify({
postDir: `${__dirname}/content`,
downloadDir: `${__dirname}/static/images/yt`,
overlayImg: `${__dirname}/play.png`
postDir: `${rootdir}/content`,
downloadDir: `${rootdir}/static/images/yt`,
overlayImg: `${rootdir}/play.png`
})

View File

@ -12,7 +12,8 @@
"@babel/preset-env": "^7.9.6"
},
"scripts": {
"jamstack": "node jamstack-init.js"
"precommit": "node hooks/precommit.js",
"postdeploy": "node hooks/postdeploy.js"
},
"repository": {
"type": "git",