Files
help/.gitea/workflows/publish.yml
T
gitea-actionsandClaude Opus 5 e9a20baf93
Publish site / build-deploy (push) Successful in 5s
ci: buildovat mimo skrytou cestu workspace
act_runner staví workspace do /root/.cache/act/..., a quarto v cestě
obsahující skrytý adresář nenajde žádné vstupní soubory: vyrobí prázdný
_site a skončí s kódem 0. Ověřeno lokálně stejnou verzí quarta.
Checkout i render proto probíhají v /tmp/quarto-build-<run_id>.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-13 18:48:31 +02:00

96 lines
3.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Publish site
on:
push:
branches: [main]
workflow_dispatch:
env:
QUARTO_VERSION: "1.10.18"
GITEA_HOST: gitea.spacilovi.eu
# Pozor: nesmí být pod skrytým adresářem. Workspace runneru je
# /root/.cache/act/... a quarto v cestě se skrytou složkou nenajde
# žádné vstupní soubory – vyrobí prázdný _site a skončí s kódem 0.
BUILD_DIR: /tmp/quarto-build-${{ github.run_id }}
jobs:
build-deploy:
# runner běží v host módu bez Node.js, proto žádné JS akce (actions/checkout apod.)
runs-on: homelab
steps:
- name: Checkout
env:
TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
set -e
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
git init -q .
git fetch --depth 1 \
"https://x-access-token:${TOKEN}@${GITEA_HOST}/${GITHUB_REPOSITORY}.git" \
"$GITHUB_REF_NAME"
git checkout -q FETCH_HEAD
- name: Install Quarto
run: |
set -e
if [ ! -x "$HOME/opt/quarto-${QUARTO_VERSION}/bin/quarto" ]; then
curl -sSL -o /tmp/quarto.tar.gz \
"https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.tar.gz"
mkdir -p "$HOME/opt"
tar -xzf /tmp/quarto.tar.gz -C "$HOME/opt"
rm -f /tmp/quarto.tar.gz
fi
- name: Render
run: |
set -e
cd "$BUILD_DIR"
"$HOME/opt/quarto-${QUARTO_VERSION}/bin/quarto" render
# pojistka: prázdný build nesmí přepsat publikovaný web
test -f _site/index.html
- name: Deploy to gh-pages
env:
TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
set -e
cd "$BUILD_DIR"
test -f _site/index.html
REMOTE="https://x-access-token:${TOKEN}@${GITEA_HOST}/${GITHUB_REPOSITORY}.git"
WT="/tmp/gh-pages-${GITHUB_RUN_ID}"
trap 'rm -rf "$WT"' EXIT
git config user.name "gitea-actions"
git config user.email "gitea-actions@spacilovi.eu"
# pracovní kopie gh-pages (zachová dosavadní historii větve)
if git ls-remote --exit-code "$REMOTE" gh-pages >/dev/null 2>&1; then
git fetch "$REMOTE" gh-pages
git worktree add "$WT" FETCH_HEAD
cd "$WT"
git checkout -B gh-pages
else
mkdir -p "$WT"
cd "$WT"
git init -q -b gh-pages
fi
# zahodit staré soubory (kromě .git) a nakopírovat nový build
find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
cp -a "${BUILD_DIR}/_site/." .
touch .nojekyll
git add -A
if git diff --cached --quiet; then
echo "Beze změn, nic se nepublikuje."
exit 0
fi
git commit -q -m "Built site for gh-pages (${GITHUB_SHA::7})"
git push "$REMOTE" HEAD:gh-pages
- name: Cleanup
if: always()
run: rm -rf "$BUILD_DIR"