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
|
# hugo.yml
|
||||||
#
|
#
|
||||||
# Takes a repository with hugo source, generates the static site and
|
# Takes a repository with Hugo source, generates the static site and
|
||||||
# pushes the result to codeberg pages
|
# pushes the result to Codeberg pages
|
||||||
#
|
#
|
||||||
# Needs a codeberg access token (cbtoken) as secret in woodpecker config
|
# Needs a codeberg access token (codeberg_token) as a secret in Woodpecker config
|
||||||
# Also uses another secret (cbmail) with email address for git 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 file in the repository is copied to the output branch so custom domains work
|
||||||
# .domains in the target repo so codeberg pages works for custom domains
|
|
||||||
#
|
#
|
||||||
# USERNAME must be replaced with your Codeberg username
|
# The HUGO_OUTPUT variable must be set to the build output folder configured in Hugo
|
||||||
# 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
|
# Recursive cloning is used to fully clone the themes given as Git submodules
|
||||||
@ -25,33 +22,30 @@ pipeline:
|
|||||||
# Build hugo static files
|
# Build hugo static files
|
||||||
build:
|
build:
|
||||||
image: klakegg/hugo
|
image: klakegg/hugo
|
||||||
|
commands:
|
||||||
|
- hugo --minify
|
||||||
when:
|
when:
|
||||||
event: [pull_request, push]
|
event: [ pull_request, push ]
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
image: bitnami/git
|
image: bitnami/git
|
||||||
# Must be set in woodpecker configuration
|
# Must be set in Woodpecker configuration
|
||||||
secrets: [ cbmail, cbtoken ]
|
secrets: [ mail, codeberg_token ]
|
||||||
|
environment:
|
||||||
|
- HUGO_OUTPUT=public
|
||||||
commands:
|
commands:
|
||||||
# Git configuration
|
# Git configuration
|
||||||
- git config --global --add safe.directory /woodpecker/src/codeberg.org/USERNAME/REPO_NAME/HUGO_OUTPUT
|
- git config --global user.email $MAIL
|
||||||
- git config --global user.email "$CBMAIL"
|
|
||||||
- git config --global user.name "Woodpecker CI"
|
- git config --global user.name "Woodpecker CI"
|
||||||
- git config --global init.defaultBranch pages
|
- git clone -b pages https://$CODEBERG_TOKEN@codeberg.org/$CI_REPO.git /tmp/$CI_REPO_NAME/
|
||||||
- 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
|
# Copy build step output to repository folder
|
||||||
- cp -a HUGO_OUTPUT/* REPO_NAME/
|
- cp -ar $HUGO_OUTPUT/. /tmp/$CI_REPO_NAME/
|
||||||
### Only needed for custom domains
|
# Needed for custom domains
|
||||||
- cp domains REPO_NAME/.domains
|
- cp .domains $HUGO_OUTPUT/ || true # Ignore if it doesn't exist
|
||||||
###
|
# Commit and push all static files with pipeline started timestamp
|
||||||
- cd REPO_NAME
|
- cd /tmp/$CI_REPO_NAME/
|
||||||
- git remote set-url origin https://$CBTOKEN@codeberg.org/USERNAME/REPO_NAME.git
|
- git add .
|
||||||
- git add --all
|
- git commit -m "Woodpecker CI ${CI_BUILD_CREATED} [CI SKIP]"
|
||||||
# Commit all static files with pipeline started timestamp
|
|
||||||
- git commit -m "Woodpecker CI ${CI_BUILD_CREATED}"
|
|
||||||
- git push
|
- git push
|
||||||
when:
|
when:
|
||||||
event: push
|
event: push
|
||||||
branch: main
|
|
Loading…
x
Reference in New Issue
Block a user