~bkhl/elektrubadur.se

ae6041e25b2f7695cb008d3c43056214d5593d10 — Björn Lindström 2 months ago ce342d0
Add CI configuration for build.sr.ht
3 files changed, 35 insertions(+), 15 deletions(-)

A .build.yml
M Containerfile
M Makefile
A .build.yml => .build.yml +21 -0
@@ 0,0 1,21 @@
---
image: fedora/latest
oauth: pages.sr.ht/PAGES:RW
packages:
  - podman
  - hut
sources:
  - https://git.sr.ht/~bkhl/elektrubadur.se
tasks:
  - complete-unless-main: >-
      git diff --quiet --exit-code origin/main || complete-build
  - publish: >-
      make -C elektrubadur.se publish
  - publish_redirect: >-
      make -C elektrubadur.se publish_redirect
  - check_links: >-
      make -C elektrubadur.se check_links
triggers:
  - action: email
    condition: failure
    to: "Björn Lindström <bkhl@elektrubadur.se>"

M Containerfile => Containerfile +2 -4
@@ 1,11 1,9 @@
FROM docker.io/library/alpine:edge
FROM docker.io/library/alpine:latest

RUN apk add --no-cache \
    bash \
    git \
    just \
    hugo \
    tzdata \
    xmlstarlet \
    tidyhtml \
    hut
    tidyhtml

M Makefile => Makefile +12 -11
@@ 3,10 3,11 @@ IMAGE := localhost/elektrubadur-builder:latest
export DOMAIN := elektrubadur.se
export OUTPUT_DIR := public

PODMAN := podman run --rm -it \
	--volume "$(HOME)/.config/hut:/root/.config/hut:z" \
	--volume "$(CURDIR):$(CURDIR):z" \
	--workdir "$(CURDIR)"
define run
podman run --rm --interactive \
--volume "$(CURDIR):$(CURDIR):z" \
--workdir "$(CURDIR)"
endef

.PHONY: all image build serve validate package publish package_redirect publish_redirect check_links



@@ 17,25 18,25 @@ image:
	podman build -f Containerfile -t $(IMAGE) .

build: image
	$(PODMAN) --env DOMAIN --env OUTPUT_DIR $(IMAGE) bash build.sh
	$(run) --env DOMAIN --env OUTPUT_DIR $(IMAGE) bash build.sh

serve: image
	$(PODMAN) --publish '1313:1313' $(IMAGE) hugo serve --bind 0.0.0.0
	$(run) --publish '1313:1313' $(IMAGE) hugo serve --bind 0.0.0.0

validate: build
	$(PODMAN) ghcr.io/validator/validator:latest vnu --skip-non-html public
	$(run) ghcr.io/validator/validator:latest vnu --skip-non-html --also-check-css --also-check-svg public

package: build validate
	tar -C public -czf public.tar.gz .

publish: package
	$(PODMAN) $(IMAGE) hut pages publish --domain $(DOMAIN) --site-config ./site-config.json public.tar.gz
	hut pages publish --domain $(DOMAIN) --site-config ./site-config.json public.tar.gz

package_redirect:
	tar -C redirect -czf redirect.tar.gz .

publish_redirect: package_redirect
	for domain in www.elektrubadur.se bkhl.elektrubadur.se bkhl.srht.site; do $(PODMAN) $(IMAGE) hut pages publish --domain $$domain --site-config ./site-config-redirect.json redirect.tar.gz; done
publish_redirect: package_redirect image
	for domain in www.elektrubadur.se bkhl.elektrubadur.se bkhl.srht.site; do hut pages publish --domain $$domain --site-config ./site-config-redirect.json redirect.tar.gz; done

check_links:
	$(PODMAN) docker.io/tennox/linkcheck:latest --external $(DOMAIN)
	$(run) docker.io/tennox/linkcheck:latest --external $(DOMAIN)