name: Zotero Addons Scraping on: workflow_dispatch: # 手动触发事件 schedule: - cron: '0 3 * * *' # 每天早上3点执行 permissions: contents: write env: TZ: Asia/Shanghai jobs: scrape_data: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: 3.x - name: Install Dependencies run: | pip install -r requirements.txt - name: Store Cache Folder uses: actions/cache/restore@v3 id: restore-cache with: path: | caches key: ${{ runner.os }}-files-${{ hashFiles('caches/caches_lockfile') }} restore-keys: | ${{ runner.os }}-files- - name: Get Cache Hash id: get-cache-hash run: | echo "CACHE_HASH=$CACHE_HASH" >> "$GITHUB_OUTPUT" env: CACHE_HASH: ${{ hashFiles('caches/caches_lockfile') }} - name: Run Script run: | python main.py \ -i addons \ -o published/addon_infos.json \ --github_repository ${GITHUB_REPOSITORY} \ --github_token ${GITHUB_TOKEN} \ --cache_directory caches \ --runtime_xpi_directory xpis \ --cache_lockfile caches_lockfile \ --previous_info_urls \ https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/publish/addon_infos.json \ https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/addon_infos.json env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish in Repository uses: peaceiris/actions-gh-pages@v3 with: deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} publish_branch: publish user_name: 'github-actions[bot]' user_email: 'github-actions[bot]@users.noreply.github.com' publish_dir: ./published - name: Check Cache Need Update id: check-cache-update run: | if [[ "$PRE_CACHE_HASH" != "$CUR_CACHE_HASH" ]]; then echo "SAVE_CACHE=true" >> "$GITHUB_OUTPUT" else echo "SAVE_CACHE=false" >> "$GITHUB_OUTPUT" fi env: PRE_CACHE_HASH: ${{ steps.get-cache-hash.outputs.CACHE_HASH }} CUR_CACHE_HASH: ${{ hashFiles('caches/caches_lockfile') }} - name: Save Cache Folder if: steps.check-cache-update.outputs.SAVE_CACHE == 'true' uses: actions/cache/save@v3 id: save-cache with: path: | caches key: ${{ runner.os }}-files-${{ hashFiles('caches/caches_lockfile') }}