Files
help/.gitea/workflows/publish.yml
T
gitea-actionsandClaude Opus 5 6215de1d35
Publish site / build-deploy (push) Failing after 7s
ci: diagnostika renderu (quarto check + debug log)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-13 18:46:51 +02:00

97 lines
3.2 KiB
YAML

name: Publish site
on:
push:
branches: [main]
workflow_dispatch:
env:
QUARTO_VERSION: "1.10.18"
GITEA_HOST: gitea.spacilovi.eu
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
cd "$GITHUB_WORKSPACE"
find . -mindepth 1 -maxdepth 1 -exec rm -rf {} +
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 "$GITHUB_WORKSPACE"
QUARTO="$HOME/opt/quarto-${QUARTO_VERSION}/bin/quarto"
echo "pwd=$(pwd)"
ls -la
"$QUARTO" --version
echo "--- quarto check ---"
"$QUARTO" check 2>&1 | head -40 || echo "check skončil s kódem $?"
echo "--- render (debug) ---"
"$QUARTO" render --log-level debug 2>&1 | tail -60 || echo "render skončil s kódem $?"
echo "--- obsah _site ---"
find _site -maxdepth 2 2>/dev/null | head -30
# 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 "$GITHUB_WORKSPACE"
# pojistka: bez index.html v _site se nepublikuje nic
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 "${GITHUB_WORKSPACE}/_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