From e9f4b4fdebed8ee999a4b2d36683706e89e53ea6 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Mon, 24 Jun 2024 23:01:38 -0400 Subject: [PATCH] Deploy with gpb-docker --- .gpb-docker.json | 7 +++++++ build/Dockerfile | 12 +++++++----- build/build | 7 +++---- 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 .gpb-docker.json diff --git a/.gpb-docker.json b/.gpb-docker.json new file mode 100644 index 0000000..fdebf81 --- /dev/null +++ b/.gpb-docker.json @@ -0,0 +1,7 @@ +[{ + "file": "build/Dockerfile", + "args": { + "COMMIT": "{{.Commit}}" + }, + "secrets": ["hugo-site/srht-token"] +}] diff --git a/build/Dockerfile b/build/Dockerfile index 507c123..e4e36e0 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,9 +1,11 @@ -FROM jasonccox/git-personal-builder:latest-arm64 -LABEL maintainer="me@jasoncarloscox.com" -EXPOSE 80 +FROM alpine:latest RUN apk add --no-cache curl RUN apk add --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community --no-cache hugo -COPY build /usr/bin/ -CMD ["build"] +WORKDIR /site +COPY . . + +ARG COMMIT +RUN --mount=type=secret,id=hugo-site/srht-token,target=/srht-token \ + ./build/build "$COMMIT" /srht-token diff --git a/build/build b/build/build index 3d0fb80..02a682e 100755 --- a/build/build +++ b/build/build @@ -1,12 +1,11 @@ #!/bin/sh set -e -cd "$(dirname "$0")" +cd "$(dirname "$0")/.." commit="${1:-$(git rev-parse HEAD)}" -dir="${2:-../}" +token_file="${2:?missing token file}" -cd "$dir" hugo echo "$commit $(date -Iseconds)" >public/version.txt @@ -15,7 +14,7 @@ tar --directory public -cz . >"$archive" curl \ --fail-with-body \ --no-progress-meter \ - --oauth2-bearer "$SRHT_TOKEN" \ + --oauth2-bearer "$(cat "$token_file")" \ --form content="@$archive" \ https://pages.sr.ht/publish/jasoncarloscox.com -- 2.45.2