Zotero Addons Scraping #2003
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Zotero Addons Scraping | |
on: | |
workflow_dispatch: # manual | |
schedule: | |
- cron: '25 4,7,10,14,19,23 * * *' # +8(beijing) | |
push: | |
branches: [master] | |
permissions: | |
contents: write | |
actions: write | |
issues: 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@v5 | |
with: | |
python-version: 3.x | |
- name: Install Dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Store Cache Folder | |
uses: actions/cache/restore@v4 | |
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 \ | |
--create_release True \ | |
# --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@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# 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@v4 | |
id: save-cache | |
with: | |
path: | | |
caches | |
key: ${{ runner.os }}-files-${{ hashFiles('caches/caches_lockfile') }} | |