mirror of
https://codeberg.org/Codeberg-CI/examples.git
synced 2025-09-08 19:35:00 -04:00
Add example for hugo and codeberg pages (#5)
An example to publish pages built with Hugo on Codeberg Pages. Thanks to [jwildeboer](https://codeberg.org/jwildeboer) for the inspiration and the explanation. Co-authored-by: Peter Prumbach <mail@peterprumbach.de> Reviewed-on: https://codeberg.org/Codeberg-CI/examples/pulls/5 Co-authored-by: Peter Prumbach <peterprumbach@noreply.codeberg.org> Co-committed-by: Peter Prumbach <peterprumbach@noreply.codeberg.org>
This commit is contained in:
parent
ab0c2ce5d7
commit
ed05614e1d
57
Hugo/hugo.yml
Normal file
57
Hugo/hugo.yml
Normal file
@ -0,0 +1,57 @@
|
||||
# hugo.yml
|
||||
#
|
||||
# Takes a repository with hugo source, generates the static site and
|
||||
# pushes the result to codeberg pages
|
||||
#
|
||||
# Needs a codeberg access token (cbtoken) as secret in woodpecker config
|
||||
# Also uses another secret (cbmail) with email address for git config
|
||||
#
|
||||
# We also assume a domains file in the source repo that gets copied to
|
||||
# .domains in the target repo so codeberg pages works for custom domains
|
||||
#
|
||||
# USERNAME must be replaced with your Codeberg username
|
||||
# REPO_NAME must be replaced with your source code repository
|
||||
# HUGO_OUTPUT must be replace with your static files output folder configured in Hugo
|
||||
#
|
||||
|
||||
# Recursive cloning is used to fully clone the themes given as Git submodules
|
||||
clone:
|
||||
git:
|
||||
image: woodpeckerci/plugin-git
|
||||
settings:
|
||||
recursive: true
|
||||
|
||||
pipeline:
|
||||
# Build hugo static files
|
||||
build:
|
||||
image: klakegg/hugo
|
||||
when:
|
||||
event: [pull_request, push]
|
||||
|
||||
publish:
|
||||
image: bitnami/git
|
||||
# Must be set in woodpecker configuration
|
||||
secrets: [ cbmail, cbtoken ]
|
||||
commands:
|
||||
# Git configuration
|
||||
- git config --global --add safe.directory /woodpecker/src/codeberg.org/USERNAME/REPO_NAME/HUGO_OUTPUT
|
||||
- git config --global user.email "$CBMAIL"
|
||||
- git config --global user.name "Woodpecker CI"
|
||||
- git config --global init.defaultBranch pages
|
||||
- git clone -b pages https://codeberg.org/USERNAME/REPO_NAME.git
|
||||
# Avoid permission denied errors
|
||||
- chmod -R a+w REPO_NAME
|
||||
# Copy build step output to repository folder
|
||||
- cp -a HUGO_OUTPUT/* REPO_NAME/
|
||||
### Only needed for custom domains
|
||||
- cp domains REPO_NAME/.domains
|
||||
###
|
||||
- cd REPO_NAME
|
||||
- git remote set-url origin https://$CBTOKEN@codeberg.org/USERNAME/REPO_NAME.git
|
||||
- git add --all
|
||||
# Commit all static files with pipeline started timestamp
|
||||
- git commit -m "Woodpecker CI ${CI_BUILD_CREATED}"
|
||||
- git push
|
||||
when:
|
||||
event: push
|
||||
branch: main
|
@ -10,6 +10,7 @@ Pull requests are accepted/welcome.
|
||||
| [C/make.yml](C/make.yml) | C | Make | Simple ci for building a Make based C project |
|
||||
| [golang/build.yml](golang/build.yml) | golang | golang | Simple ci for building and test a Go project |
|
||||
| [golang/build-docker.yml](golang/build-docker.yml) | golang | golang / kaniko | CI to build golang project and build various docker container and publish them on DockerHub |
|
||||
| [Hugo/hugo.yml](Hugo/hugo.yml) | Markdown | Hugo | CI step to build static website files and publish them to Codeberg Pages with Hugo |
|
||||
|
||||
# More:
|
||||
https://codeberg.org/explore/repos?q=woodpecker-ci&topic=1
|
||||
|
Loading…
x
Reference in New Issue
Block a user