From aba4aa3b131e1f5b947f11870c84577e685d9b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?CC=E5=BA=B7=E7=BA=B3=E7=99=BE=E5=B7=9D?= Date: Thu, 5 Sep 2024 00:01:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=EF=BC=8C=E5=87=8F=E5=B0=91=E5=AF=B9=E4=B8=8B=E6=B8=B8=E5=BD=B1?= =?UTF-8?q?=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新工作流,减少对下游影响 --- .github/workflows/friend_circle_lite.yml | 74 +++++++++++++++++++----- 1 file changed, 60 insertions(+), 14 deletions(-) diff --git a/.github/workflows/friend_circle_lite.yml b/.github/workflows/friend_circle_lite.yml index 64b16a6..32e5aaf 100644 --- a/.github/workflows/friend_circle_lite.yml +++ b/.github/workflows/friend_circle_lite.yml @@ -14,33 +14,79 @@ jobs: steps: - name: Pull Latest Repository - uses: actions/checkout@v3 - - - name: Install Python - uses: actions/setup-python@v4 + uses: actions/checkout@v4 + + - name: Cache pip packages + uses: actions/cache@v4 with: - python-version: '3.x' - + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - + + - name: Download last_articles.json artifact + uses: dawidd6/action-download-artifact@v6 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + branch: main + name: 'last_articles' + path: './rss_subscribe' + if_no_artifact_found: warn + - name: Check RSS feeds env: SMTP_PWD: ${{ secrets.SMTP_PWD }} run: | python run.py - + + - name: Upload last_articles.json as artifact + uses: actions/upload-artifact@v4 + with: + name: 'last_articles' + path: './rss_subscribe/last_articles.json' + retention-days: 90 + - name: git config run: | - git config --global user.name 'GitHub Actions' - git config --global user.email 'actions@github.com' + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' - name: Commit changes - env: - PAT_TOKEN: ${{ secrets.PAT_TOKEN }} run: | + mkdir pages + cp -r main index.html all.json errors.json pages/ + cd pages + git init git add . - git commit -m "⏱️GitHub Action定时更新" - git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git main + git commit -m "⏱️ $(date +"%Z %Y-%m-%d %A %H:%M:%S") Updated By GitHub Actions" + git push --force https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:gh-pages + + - name: Delete Workflow Runs + uses: Mattraks/delete-workflow-runs@v2 + with: + retain_days: 90 + keep_minimum_runs: 6 + + keepalive-workflow: + name: Keepalive Workflow + if: ${{ always() }} + needs: friend-circle-lite + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - uses: actions/checkout@v4 + - uses: gautamkrishnar/keepalive-workflow@v2 + with: + committer_username: "github-actions[bot]" + committer_email: "github-actions[bot]@users.noreply.github.com"