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