From 79edf61eebc5668f7fabe63df8904bf4776722db Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Sun, 14 Sep 2025 19:10:17 +0100 Subject: [PATCH] Add CI Signed-off-by: Nikolaos Karaolidis --- .gitattributes | 1 + .gitea/Containerfile | 6 ++++ .gitea/workflows/main.yaml | 64 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 .gitea/Containerfile create mode 100644 .gitea/workflows/main.yaml diff --git a/.gitattributes b/.gitattributes index 31c24ae..45a81e0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ +*.webp filter=lfs diff=lfs merge=lfs -text *.jpeg filter=lfs diff=lfs merge=lfs -text *.jpg filter=lfs diff=lfs merge=lfs -text *.png filter=lfs diff=lfs merge=lfs -text diff --git a/.gitea/Containerfile b/.gitea/Containerfile new file mode 100644 index 0000000..0681c2f --- /dev/null +++ b/.gitea/Containerfile @@ -0,0 +1,6 @@ +FROM ghcr.io/catthehacker/ubuntu:act-latest + +RUN HUGO_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.tag_name') \ + && curl -L -o /tmp/hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/${HUGO_VERSION}/hugo_extended_${HUGO_VERSION#v}_Linux-64bit.tar.gz" \ + && tar -xzf /tmp/hugo.tar.gz -C /usr/local/bin hugo \ + && rm /tmp/hugo.tar.gz diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml new file mode 100644 index 0000000..df97193 --- /dev/null +++ b/.gitea/workflows/main.yaml @@ -0,0 +1,64 @@ +name: Build and Release Site + +on: + push: + branches: + - "**" + +jobs: + builder: + uses: karaolidis/workflows/.gitea/workflows/builder.yaml@main + with: + registry: git.karaolidis.com + username: ${{ github.repository_owner }} + secrets: + password: ${{ secrets.REGISTRY_PASSWORD }} + + release: + runs-on: nix + needs: builder + container: + image: ${{ needs.builder.outputs.tag }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + persist-credentials: true + + # FIXME: https://github.com/actions/checkout/issues/1830 + - name: Checkout LFS (including submodules) + run: | + git lfs install --local + AUTH=$(git config --local http.${GITHUB_SERVER_URL}/.extraheader) + git config --local --unset http.${GITHUB_SERVER_URL}/.extraheader + git config --local http.${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git/info/lfs/objects/batch.extraheader "$AUTH" + git lfs pull + + - name: Build Site + run: | + cd themes/caldwell + npm install + cd ../.. + ln -s ./themes/caldwell/node_modules node_modules + hugo --config hugo.toml --minify + + - name: Package Site + run: | + cd public + tar -czvf ../site.tar.gz * + + - name: Release + uses: https://github.com/akkuman/gitea-release-action@main + with: + name: "Release ${{ github.sha }}" + tag_name: "release-${{ github.sha }}" + files: site.tar.gz + + - name: Publish + env: + TARGET_URL: https://blog.karaolidis.com/upload + run: | + curl -X POST "$TARGET_URL" \ + -H "Authorization: ${{ secrets.BLOG_API_KEY }}" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @site.tar.gz