From c9e5e8de3edfd78033a9a964f0ed8e776edeaf51 Mon Sep 17 00:00:00 2001
From: Andrea Ciceri <andrea.ciceri@autistici.org>
Date: Thu, 14 Mar 2024 19:13:37 +0100
Subject: [PATCH] [CI] Forgejo actions

---
 .forgejo/workflows/build.yaml             | 11 +++++++
 .forgejo/workflows/update-flake-lock.yaml | 35 +++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 .forgejo/workflows/build.yaml
 create mode 100644 .forgejo/workflows/update-flake-lock.yaml

diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml
new file mode 100644
index 0000000..722d220
--- /dev/null
+++ b/.forgejo/workflows/build.yaml
@@ -0,0 +1,11 @@
+on:
+  push:
+    branches: ["*"]
+jobs:
+  test:
+    runs-on: nix
+    steps:
+      - uses: actions/checkout@v4
+        name: Checkout repository
+      - name: Build with nix
+        run: nix-fast-build --no-nom
diff --git a/.forgejo/workflows/update-flake-lock.yaml b/.forgejo/workflows/update-flake-lock.yaml
new file mode 100644
index 0000000..2c32778
--- /dev/null
+++ b/.forgejo/workflows/update-flake-lock.yaml
@@ -0,0 +1,35 @@
+name: update-flake-lock
+on:
+  schedule:
+    - cron: '46 20 * * *' # daily at 14:30
+
+jobs:
+  lockfile:
+    runs-on: nix
+    steps:
+      - uses: actions/checkout@v4
+        name: Checkout repository
+        with:
+          token: ${{secrets.SEVENOFNINE_TOKEN}}
+      - name: Create new branch from the checked out one
+        run: git switch -c update-flake-lock
+      - name: Configure git as `Seven of Nix`
+        run: |
+          git config --global user.email "sevenofnine@stronzi.org"
+          git config --global user.name "Seven of Nine"
+      - name: Update flake's lockfile and create commit
+        run: nix flake update --commit-lock-file --override-input ccrEmacs "git+https://git.aciceri.dev/aciceri/emacs.git"
+      - name: Push commit to the `update-flake-lock` remote branch
+        run: git push origin --force update-flake-lock # sevenOfNix needs write access to the repository
+      - name: Login as `Seven of Nix`
+        run: |
+          tea logins add --token ${{secrets.SEVENOFNINE_TOKEN}} --url https://git.aciceri.dev
+          tea logins default git.aciceri.dev
+      - name: Create the pull request
+        run: |
+          tea pulls create \
+            --repo "$GITHUB_REPOSITORY" \
+            --title "Update flake's lockfile" \
+            --description "Check the commit description for inputs deltas" \
+            --assignees aciceri \
+            || echo "PR already existing"