From e73504b4b636d45839ad64c3b007db3adee93e0c Mon Sep 17 00:00:00 2001
From: trli <potter@trli.club>
Date: Mon, 15 Jan 2024 09:52:44 +0800
Subject: [PATCH] Create go-update.yml

---
 .github/workflows/go-update.yml | 44 +++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 .github/workflows/go-update.yml

diff --git a/.github/workflows/go-update.yml b/.github/workflows/go-update.yml
new file mode 100644
index 0000000..8df9df4
--- /dev/null
+++ b/.github/workflows/go-update.yml
@@ -0,0 +1,44 @@
+name: go-update
+on:
+  workflow_dispatch:
+  schedule:
+    - cron: "0 0 * *  */7"
+jobs:
+  go:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Setup Go 1.x.y
+        uses: actions/setup-go@main
+        with:
+          go-version: ^1.21
+      - name: Checkout codebase
+        uses: actions/checkout@main
+
+      - name: go
+        run: |
+          cd ./server
+          go mod tidy -compat=1.21
+          gofmt -w -r 'interface{} -> any' .
+          go get -u
+          go mod download
+          go get -u
+          go mod download
+
+      - name: Git push 
+        run: |
+          git init
+          git config --local user.name "github-actions[bot]"
+          git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
+          git remote rm origin
+          git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUBTOKEN }}@github.com/${{ github.repository }}"
+          git gc --aggressive
+          git add --all
+          git commit -m "update go.mod $(date +%Y.%m.%d.%H.%M)"
+          git push -f -u origin dev
+          
+    # 删除无用 workflow runs;
+      - name: Delete workflow runs
+        uses: GitRML/delete-workflow-runs@main
+        with:
+          retain_days: 0.1
+          keep_minimum_runs: 1