From 83606ba31083fbc74ed4d5aeb22a343c55ee0d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=BF=83=E7=A6=BE?= Date: Sun, 12 Nov 2023 13:44:33 +0800 Subject: [PATCH] ci: test auto fetch --- .github/workflows/fetch.yml | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/fetch.yml b/.github/workflows/fetch.yml index e688649811..3ca8b5c0b3 100644 --- a/.github/workflows/fetch.yml +++ b/.github/workflows/fetch.yml @@ -2,9 +2,8 @@ name: Fetch data on: - schedule: - # Runs at 00:00 UTC. - - cron: "0 0 * * *" + push: + branches: [dev] permissions: contents: write @@ -25,12 +24,32 @@ jobs: - name: Fetch run: go run ./cmd/fetch - - name: Commit + - name: Configure git run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Commit + id: commit + continue-on-error: true + run: | git add src/contests.json public/users.json - git diff-index --quiet HEAD || git commit -m "Fetch data" + git commit -m "Fetch data" - name: Push + if: ${{ steps.commit.outcome == 'success' }} run: git push + + - name: Extract user data + if: ${{ steps.commit.outcome == 'success' }} + run: go run ./cmd/extract + + - name: Commit public/users/ + if: ${{ steps.commit.outcome == 'success' }} + run: | + git add -f public/users/ + git commit -m "Extract user data" + + - name: Push to dist + if: ${{ steps.commit.outcome == 'success' }} + run: git push -f origin main:dist