diff --git a/Hugo/hugo.yml b/Hugo/hugo.yml index 6219fad..41fcf11 100644 --- a/Hugo/hugo.yml +++ b/Hugo/hugo.yml @@ -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 \ No newline at end of file