First stabs at full implementation

This commit is contained in:
Jack Jackson 2025-02-25 18:41:37 -08:00
parent 0ccb8bbbc0
commit 5d85e81aeb

View File

@ -3,13 +3,9 @@ run-name: ${{ gitea.actor }} is testing out Gitea Actions! 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
checkout:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
# Despite not being present in the QuickStart instructions, this step is necessary in order to install `node`,
# which is itself required for `actions/checkout`
# Cannot use `actions/setup-node` because that _itself_ requires `node` (it makes it available to user-code,
@ -20,9 +16,44 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
block-posts-containining-tk:
depends-on:
- checkout
runs-on: busybox
steps:
- run: |
# This is necessary because, if `grep ...` doesn't find anything, it will _return_ (not print) a value of 1
# (non-zero return codes indicating errors in Unix - since there are many more ways for something to go wrong
# than there are for it to go right!), and so the `files=` assignment will also return 1, and the whole operation
# will be considered a failure.
#
# Since a non-zero value is truthy in Linux, we can use the OR operator (`||`) to only execute the second command
# if the first one errors out. So, this line can be translated to English as:
# "Set the variable `files` to a list of all the files that contain `TK` - unless there aren't any, in which case
# set it to `FILES NOT FOUND"
files=$(grep -rl 'TK' blog/content/posts || echo "FILES NOT FOUND")
# We have to filter out (`grep -v`) the "marker" value of `FILES NOT FOUND`, otherwise the no-matches case would
# be recorded as having 1 matching file, leading to an error-out below.
# (I guess _technically_ there's an edge case in that, if I ever make a blog post titled "FILES NOT FOUND" _which also_
# contains the string `TK`, it would slip through this check. But that feels pretty unlikely - not least because spaces
# are very rare in my filesystem names - so I'm ok taking that risk)
count=$(wc -l <(echo "$files" | grep -v "FILES NOT FOUND") | awk '{print $1}')
if [[ "$count" -gt "0" ]]; then
echo "Found TK in $count files:"
echo $files
exit 1 # TODO - and alerting via Telegram!
fi
build-blog:
depends-on:
- block-posts-containining-tk
runs-on: alpine
steps:
- run: |
apt-get update && apt-get install -y hugo git
git submodule init
git submodule update --recursive
hugo --source blog
# TODO - build image, then publish