Dough Git

commit

Add mirror to keep data safe

commit
5b81db426dfb1a82ef8dae267de9cfe6644c7847
author
Clove <[email protected]>
date
2026-11-24 13:18

diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml
new file mode 100644
index 0000000..e71eb13
--- /dev/null
+++ b/.github/workflows/mirror.yml
@@ -0,0 +1,58 @@
+name: Mirror
+
+on:
+  push:
+
+jobs:
+  mirror:
+    runs-on: ubuntu-latest
+
+    permissions:
+      contents: read
+
+    concurrency:
+      group: mirror-${{ github.repository }}
+      cancel-in-progress: false
+
+    env:
+      MIRROR_TOKEN: ${{ secrets.MIRROR_TOKEN }}
+
+    steps:
+      - name: Clone every ref
+        env:
+          SOURCE_TOKEN: ${{ github.token }}
+          SERVER_URL: ${{ github.server_url }}
+        run: |
+          set -euo pipefail
+
+          sourceHost="${SERVER_URL#https://}"
+
+          git clone --mirror \
+            "https://x-access-token:${SOURCE_TOKEN}@${sourceHost}/${GITHUB_REPOSITORY}.git" \
+            source.git
+
+      - name: Drop pull-request refs
+        working-directory: source.git
+        run: |
+          set -euo pipefail
+
+          git for-each-ref --format='%(refname)' 'refs/pull/*' \
+            | while read -r ref; do
+                git update-ref -d "$ref"
+              done
+
+      - name: Push mirror
+        working-directory: source.git
+        run: |
+          set -euo pipefail
+
+          targetUrl="https://git.doughmination.gay/clove/proxyBot.git"
+
+          echo "Mirroring ${GITHUB_REPOSITORY} -> ${targetUrl}"
+
+          git remote add mirror "$targetUrl"
+
+          # Credentials go through a helper so the token never lands in .git/config
+          git -c credential.helper= \
+              -c "credential.helper=!f() { echo username="clove"; echo password=\"\$MIRROR_TOKEN\"; }; f" \
+              push --mirror mirror