Using Gitea/Github actions for triggering Echo
Published:
I decided to start using Robb Knight’s Echo tool, to syndicate my blog posts to Mastodon, and trigger Webmentions. I’m not going to go through the configuration of Echo here, the project README has some good instructions for setting it up.
However, I have just started using Gitea Actions for CI on my private Git server, so I’m using a scheduled action to achieve this:
name: Syndicate using echo
on:
schedule:
- cron: '*/5 * * * *'
jobs:
echo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install dependencies 📦
run: npm ci
- name: Cache build
id: cache-data
uses: actions/cache@v4
with:
path: data
key: cache-data-${{ gitea.run_id }}
restore-keys: |
cache-data
- uses: actions/setup-go@v3
with:
go-version: '1.20'
- uses: https://gitea.com/actions/go-hashfiles@v0.0.1
id: get-hash
with:
patterns: |-
./data/*
- name: Init echo
if: ${{ steps.get-hash.outputs.hash == ''}}
run: node index.js init
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_URL: ${{ secrets.MASTODON_URL }}
- name: Run echo
run: node index.js
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_URL: ${{ secrets.MASTODON_URL }}
This:
- Checks out the code
- Sets up node
- Uses the cache action to persist the
data
directory between runs - Uses the
go-hashfiles
action to calculate a hash of the data directory[1] - If the hash is empty, initialise Echo
- Run echo
If using Github Actions, you can remove these steps and just use the
hashFiles
function ↩︎