From 6d144bd7014731bdeaae72f342a987c779cc3a59 Mon Sep 17 00:00:00 2001
From: Gabriel Arazas <foodogsquared@foodogsquared.one>
Date: Tue, 19 Nov 2024 11:15:18 +0800
Subject: [PATCH] Allow lockfile updates in CI

---
 .github/workflows/update-deps.yml | 30 ++++++++++++++++++++++++++++++
 Makefile                          |  4 ++++
 2 files changed, 34 insertions(+)
 create mode 100644 .github/workflows/update-deps.yml

diff --git a/.github/workflows/update-deps.yml b/.github/workflows/update-deps.yml
new file mode 100644
index 0000000..5afcaef
--- /dev/null
+++ b/.github/workflows/update-deps.yml
@@ -0,0 +1,30 @@
+name: Update Nix dependencies
+on:
+  workflow_dispatch:
+  schedule:
+    # This is done on a biweekly basis.
+    - cron: '0 0 1,15 * *'
+
+jobs:
+  update-nix-deps:
+    permissions:
+      contents: write
+      pull-requests: write
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - uses: DeterminateSystems/nix-installer-action@v16
+      - run: nix develop --command make update
+      - id: datetime
+        run: |
+          echo "DATETIME=$(date '+%F')" >> "$GITHUB_OUTPUT"
+      - name: Create pull request
+        uses: peter-evans/create-pull-request@v7
+        with:
+          title: "ci: update lockfile as of ${{ steps.datetime.outputs.DATETIME }}"
+          delete-branch: true
+          branch: update-flake-lockfile
+          body: ""
+          commit-message: |
+            Update flake lockfile as of ${{ steps.datetime.outputs.DATETIME }}
+          labels: flake-update
diff --git a/Makefile b/Makefile
index 59c6fd4..056de87 100644
--- a/Makefile
+++ b/Makefile
@@ -9,3 +9,7 @@ update:
 .PHONY : build-demo
 build-demo:
 	hugo -s ./exampleSite
+
+.PHONY : dev-update
+dev-update:
+	nix flake update