mirror of
https://codeberg.org/Codeberg-CI/examples.git
synced 2025-09-11 12:55:19 -04:00
hugo: simplify (#9)
- Clone writable repo in /tmp/. - Use writable URL at clone instead of setting remote. Co-authored-by: kt programs <ktprograms@gmail.com> Reviewed-on: https://codeberg.org/Codeberg-CI/examples/pulls/9 Co-authored-by: ktprograms <ktprograms@noreply.codeberg.org> Co-committed-by: ktprograms <ktprograms@noreply.codeberg.org>
This commit is contained in:
parent
5bcec8c1e4
commit
5031ce2d6e
@ -1,17 +1,14 @@
|
||||
# hugo.yml
|
||||
#
|
||||
# Takes a repository with hugo source, generates the static site and
|
||||
# pushes the result to codeberg pages
|
||||
# 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
|
||||
# Needs a codeberg access token (codeberg_token) as a secret in Woodpecker config
|
||||
# Also uses another secret (mail) 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
|
||||
# .domains file in the repository is copied to the output branch so custom domains work
|
||||
#
|
||||
# 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
|
||||
# The HUGO_OUTPUT variable must be set to the build output folder configured in Hugo
|
||||
#
|
||||
|
||||
# Recursive cloning is used to fully clone the themes given as Git submodules
|
||||
@ -25,33 +22,30 @@ pipeline:
|
||||
# Build hugo static files
|
||||
build:
|
||||
image: klakegg/hugo
|
||||
commands:
|
||||
- hugo --minify
|
||||
when:
|
||||
event: [pull_request, push]
|
||||
event: [ pull_request, push ]
|
||||
|
||||
publish:
|
||||
image: bitnami/git
|
||||
# Must be set in woodpecker configuration
|
||||
secrets: [ cbmail, cbtoken ]
|
||||
# Must be set in Woodpecker configuration
|
||||
secrets: [ mail, codeberg_token ]
|
||||
environment:
|
||||
- HUGO_OUTPUT=public
|
||||
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.email $MAIL
|
||||
- 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
|
||||
- git clone -b pages https://$CODEBERG_TOKEN@codeberg.org/$CI_REPO.git /tmp/$CI_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}"
|
||||
- cp -ar $HUGO_OUTPUT/. /tmp/$CI_REPO_NAME/
|
||||
# Needed for custom domains
|
||||
- cp .domains $HUGO_OUTPUT/ || true # Ignore if it doesn't exist
|
||||
# Commit and push all static files with pipeline started timestamp
|
||||
- cd /tmp/$CI_REPO_NAME/
|
||||
- git add .
|
||||
- git commit -m "Woodpecker CI ${CI_BUILD_CREATED} [CI SKIP]"
|
||||
- git push
|
||||
when:
|
||||
event: push
|
||||
branch: main
|
Loading…
x
Reference in New Issue
Block a user