ci: publikace webu na gh-pages přes Gitea Actions
Publish site / build-deploy (push) Has been cancelled
Publish site / build-deploy (push) Has been cancelled
Při pushi do main se vyrenderuje Quarto web a obsah _site/ se překlopí do větve gh-pages (historie větve zůstává zachována). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
702bb25eef
commit
6f8105c33a
1 file changed
+63
@@ -0,0 +1,63 @@
|
||||
name: Publish site
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
QUARTO_VERSION: "1.10.18"
|
||||
|
||||
jobs:
|
||||
build-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Quarto
|
||||
run: |
|
||||
set -e
|
||||
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"
|
||||
echo "$HOME/opt/quarto-${QUARTO_VERSION}/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Render
|
||||
run: quarto render
|
||||
|
||||
- name: Deploy to gh-pages
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
set -e
|
||||
REMOTE="https://x-access-token:${TOKEN}@gitea.spacilovi.eu/${GITHUB_REPOSITORY}.git"
|
||||
|
||||
git config --global user.name "gitea-actions"
|
||||
git config --global 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 /tmp/gh-pages FETCH_HEAD
|
||||
cd /tmp/gh-pages
|
||||
git checkout -B gh-pages
|
||||
else
|
||||
mkdir -p /tmp/gh-pages
|
||||
cd /tmp/gh-pages
|
||||
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
|
||||
Reference in new issue
Block a user