Add Zola example (#53)

An example workflow to push pages built with [Zola](https://www.getzola.org) to Codeberg Pages.

Reviewed-on: https://codeberg.org/Codeberg-CI/examples/pulls/53
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: daudix <ddaudix@gmail.com>
Co-committed-by: daudix <ddaudix@gmail.com>
This commit is contained in:
daudix 2024-07-22 22:22:58 +00:00 committed by 6543
parent 0e1cfcc3fe
commit 4be3316c10

53
Zola/.woodpecker.yaml Normal file
View File

@ -0,0 +1,53 @@
# Takes a repository with Zola source, generates the static site and
# pushes the result to the pages branch of the same repository
#
# Must be set in Woodpecker configuration:
# mail: Your email address used by Codeberg
# codeberg_token: Codeberg access token with "write:repository" permission
#
# .domains file can be put inside static folder in Zola source
#
# Exclude the pipeline to run on the pages branch
when:
branch:
exclude: pages
# Clone recursively to fully clone the themes given as Git submodules
clone:
git:
image: woodpeckerci/plugin-git
settings:
recursive: true
steps:
# Build Zola static files
build:
image: alpine:edge
commands:
- apk add zola
- zola build
when:
event: [push, pull_request]
publish:
image: bitnami/git
secrets: [mail, codeberg_token]
commands:
# Configure Git
- git config --global user.email $MAIL
- git config --global user.name "Woodpecker CI"
# Clone the output branch
- git clone --branch pages https://$CODEBERG_TOKEN@codeberg.org/$CI_REPO.git $CI_REPO_NAME
# Enter the output branch
- cd $CI_REPO_NAME
# Remove old files
- git rm -r "*" || true # Don't fail if there's nothing to remove
# Copy the output of the build step
- cp -ar ../public/. .
# Commit and push all static files with the source commit hash
- git add --all
- git commit -m "Woodpecker CI ${CI_COMMIT_SHA} [SKIP CI]" --allow-empty
- git push
when:
event: [push]