mirror of
https://codeberg.org/Codeberg-CI/examples.git
synced 2025-09-09 03:45:32 -04:00
Add NodeJS based solution (#23)
I've been able to successfully make a NodeJS based CI solution to build pages for a static site using eleventy ([11ty.dev](https://11ty.dev)). ## Overview This process will make use of the following - Source repo to contain the source code - Destination repo that will be used to serve the pages - Codeberg CI (early access) - Secrets within the CI ## How it works Currently the `.Woodpecker.yml` file will live in your source codes repo, and have the build commands. Find more [here](https://codeberg.org/cjerrington/eleventy-base-blog-source/src/branch/main/.woodpecker.yml). For the CI we will start by using the node image, setup the secrets, and build commands. The use of secrets keeps your information secured and only accessed by the build system. This is beneficial for the email and access token. During the build, the pipeline will clone the source repo, then move into our commands. We will use the default build dir by 11ty of `_site`. The pipeline will clone our destination repo as _site, then set the remote url for the push after we run our install and build. Once built, it will change directory to the build site and perform our commit and push. ## Accessing the site On the remote repo we need the default repo to be named pages. This is also houw [Codeberg Pages](https://docs.codeberg.org/codeberg-pages/) setups up the access to what serves the pages we just built. You can follow their documentation on how to access your build site based on `username.codeberg.page`. Co-authored-by: Clayton Errington <me@claytonerrington.com> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/Codeberg-CI/examples/pulls/23 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: Clayton Errington <cjerrington@noreply.codeberg.org> Co-committed-by: Clayton Errington <cjerrington@noreply.codeberg.org>
This commit is contained in:
parent
562fafda11
commit
638b4f4df4
@ -15,3 +15,4 @@ pipeline:
|
||||
- woodpecker-cli lint Rust/
|
||||
- woodpecker-cli lint Python/
|
||||
- woodpecker-cli lint tectonic/
|
||||
- woodpecker-cli lint NodeJS/11ty.yml
|
51
NodeJS/11ty.yml
Normal file
51
NodeJS/11ty.yml
Normal file
@ -0,0 +1,51 @@
|
||||
# NodeJS / 11ty on Woodpecker to codeberg pages
|
||||
#
|
||||
# https://cjerrington.codeberg.page/eleventy-base-blog-site/blog/codebergpagesbuild/
|
||||
#
|
||||
# This file would typically be .woodpecker.yml in the root of your repository.
|
||||
#
|
||||
# Takes a repository with 11ty source, generates the static site and
|
||||
# pushes the result to codeberg pages
|
||||
#
|
||||
#
|
||||
# SECRETS
|
||||
# https://woodpecker-ci.org/docs/usage/secrets
|
||||
# CBTOKEN needs a codeberg access token as secret in woodpecker config
|
||||
# CBMAIL with email address for git config
|
||||
# SOURCEREPO must be replaced with the source repo
|
||||
# DESTREPO must be replaced with the target codeberg pages repo
|
||||
# CBUSERNAME must be replaced with the user/org
|
||||
#
|
||||
#
|
||||
# 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
|
||||
#
|
||||
pipeline:
|
||||
build:
|
||||
# Use the official jekyll build container
|
||||
image: node
|
||||
secrets: [ cbtoken, cbmail, cbusername, sourcerepo, destrepo ]
|
||||
commands:
|
||||
# Avoid permission denied errors
|
||||
- chmod -R a+w .
|
||||
# Set up git in a working way
|
||||
- git config --global --add safe.directory /woodpecker/src/codeberg.org/$CBUSERNAME/$SOURCEREPO/_site
|
||||
- git config --global user.email "$CBMAIL"
|
||||
- git config --global user.name "CI Builder"
|
||||
# clone and move the target repo
|
||||
- git clone -b pages https://codeberg.org/$CBUSERNAME/$DESTREPO.git _site
|
||||
- chmod -R a+w _site
|
||||
- cd _site
|
||||
# Prepare for push
|
||||
- git remote set-url origin https://$CBTOKEN@codeberg.org/$CBUSERNAME/$DESTREPO.git
|
||||
- cd ..
|
||||
# Run 11ty build stage
|
||||
- npm install
|
||||
- npm run build
|
||||
# Only needed for custom domains
|
||||
#- cp domains _site/.domains
|
||||
# Push to target
|
||||
- cd _site
|
||||
- git add --all
|
||||
- git commit -m "Woodpecker CI 11ty Build at $( env TZ=America/Chicago date +"%Y-%m-%d %X %Z" )"
|
||||
- git push -u origin pages
|
@ -19,6 +19,7 @@ Pull requests are accepted/welcome.
|
||||
| [Python/.woodpecker.yml](Python) | Python | Python venv | Standard CI pipeline to test Python packages code on multiple Python distributions. For details check [serial-sphinx](https://codeberg.org/sail.black/serial-sphinx.git) |
|
||||
| [Rust/.woodpecker.yml](Rust) | Rust | cargo | Simple CI pipeline to run cargo commands |
|
||||
| [tectonic/.woodpecker.yml](tectonic/.woodpecker.yml) | LaTeX | Tectonic | Builds a TeX file and pushes the resulting PDF file to a given repository. |
|
||||
| [NodeJS/11ty.yml](NodeJS/11ty.yml) | JavaScript | NodeJS | CI to build static websites files and publish them to Codeberg Pages with 11ty |
|
||||
|
||||
# More:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user