From d03828724f9dd9995f5112145a2f30630dc327fe Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 1 Jul 2024 09:58:59 +0200 Subject: [PATCH 1/2] feat(workflows): add CI/CD pipeline for static site Set up a GitHub Actions workflow to build and deploy the static site from the 'static' branch to the 'pages' branch. This workflow includes steps to install dependencies, generate the static site using Python, and handle deployment through Git configuration and git commands. --- .forgejo/workflows/build.yml | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .forgejo/workflows/build.yml diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml new file mode 100644 index 0000000..fede6ea --- /dev/null +++ b/.forgejo/workflows/build.yml @@ -0,0 +1,50 @@ +name: Build and Deploy Static Site + +on: + push: + branches: + - static + +jobs: + build: + runs-on: node:20-bookworm + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install dependencies + run: | + apt update + apt install -y python3 python3-pip + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Generate static site + run: python main.py + + - name: Deploy to pages branch + run: | + # Configure Git + git config --global user.name "Forgejo" + git config --global user.email "noreply@private.coffee" + + # Move generated static site files to a temporary location + mv build ../static_site_temp + + # Create a new orphan branch named 'pages' + git checkout --orphan pages + + # Remove all files from the working directory + git rm -rf . + + # Move the static site files back to the working directory + mv ../static_site_temp/* ./ + mv ../static_site_temp/.* ./ 2>/dev/null || true + + # Add and commit the static site files + git add . + git commit -m "Deploy static site" + + # Force push to the 'pages' branch + git push origin pages --force From 7d23e465e2c99a81b1295626eb8a30a6bff9a8b2 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 1 Jul 2024 09:59:48 +0200 Subject: [PATCH 2/2] fix(build): switch to container for build jobs Replaces `runs-on` with `container` to utilize a Docker container for node:20-bookworm. This enhances consistency and reproducibility by standardizing the build environment across different runs. --- .forgejo/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index fede6ea..ec34db4 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: node:20-bookworm + container: node:20-bookworm steps: - name: Checkout repository