From fe9c5a09735235972090d705abca0826676aa0de Mon Sep 17 00:00:00 2001
From: Nicola Belluti <nicolabelluti@protonmail.com>
Date: Thu, 2 Jan 2025 17:15:18 +0100
Subject: [PATCH] Added CI/CD pipeline

---
 .gitea/workflows/build-and-publish.yaml | 33 +++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 .gitea/workflows/build-and-publish.yaml

diff --git a/.gitea/workflows/build-and-publish.yaml b/.gitea/workflows/build-and-publish.yaml
new file mode 100644
index 0000000..c5ac6db
--- /dev/null
+++ b/.gitea/workflows/build-and-publish.yaml
@@ -0,0 +1,33 @@
+name: Build and Publish
+
+on:
+  push:
+    branches:
+      - main
+
+jobs:
+  build:
+    container: docker.io/alpine:3.21
+    steps:
+        # TODO: Use Nix Flakes
+      - name: Install the dependencies
+        run: |
+          apk update &&
+          apk add hugo git npm &&
+          npm install -g wrangler                              
+
+      - name: Checkout the code
+        uses: actions/checkout@v3
+        with:
+          submodules: recursive
+
+      - name: Build the blog
+        run: hugo --gc
+
+      - name: Upload the files to Cloudflare Pages
+        run: npx wrangler pages deploy $DIRECTORY --project-name=$PROJECT_NAME
+        env:
+          CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
+          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+          PROJECT_NAME: little-emulator
+          DIRECTORY: public