From 01be5e4006f2dac414a0f3dfaf5728a53fcf32ec Mon Sep 17 00:00:00 2001 From: Frankie <1426203851@qq.com> Date: Sat, 3 Aug 2024 18:17:14 +0800 Subject: [PATCH] ci: update workflow --- .github/workflows/update-readme.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml index 4f725b3b..3fa11355 100644 --- a/.github/workflows/update-readme.yml +++ b/.github/workflows/update-readme.yml @@ -20,11 +20,6 @@ jobs: - name: Install dependencies run: npm install - - name: Configure git - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' - - name: Pull latest changes run: git pull origin main @@ -33,10 +28,22 @@ jobs: GITHUB_TOKEN: ${{ secrets.WORKFLOW_GITHUB_TOKEN }} run: node scripts/update-readme.js + - name: Check if README.md has changed + id: check_changes + run: | + if git diff --exit-code README.md; then + echo "file_changed=false" >> $GITHUB_ENV + else + echo "file_changed=true" >> $GITHUB_ENV + fi + - name: Commit changes + if: env.file_changed == 'true' env: GITHUB_TOKEN: ${{ secrets.WORKFLOW_GITHUB_TOKEN }} run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' git add README.md git commit -m "docs: update readme" git push origin main