|
| 1 | +name: Regular Auto Update |
| 2 | + |
| 3 | +env: |
| 4 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 5 | + |
| 6 | +on: |
| 7 | + schedule: |
| 8 | + # 每两周的周一凌晨2点运行 |
| 9 | + - cron: '0 2 * * 1/2' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + pull-requests: write |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: auto-scrape |
| 18 | + cancel-in-progress: false |
| 19 | + |
| 20 | +jobs: |
| 21 | + scrape-commit: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v5 |
| 27 | + with: |
| 28 | + submodules: recursive |
| 29 | + |
| 30 | + - name: Setup Python |
| 31 | + uses: actions/setup-python@v6 |
| 32 | + with: |
| 33 | + python-version: '3.11' |
| 34 | + |
| 35 | + - name: Setup Node.js |
| 36 | + uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: '20' |
| 39 | + |
| 40 | + - name: Detect scraper directory |
| 41 | + run: | |
| 42 | + if [ -x "./sp" ]; then |
| 43 | + echo "SCRAPER_DIR=." >> "$GITHUB_ENV" |
| 44 | + elif [ -x "./dblp-publications-scraper/sp" ]; then |
| 45 | + echo "SCRAPER_DIR=./dblp-publications-scraper" >> "$GITHUB_ENV" |
| 46 | + else |
| 47 | + echo "Cannot find sp launcher. Checked ./sp and ./dblp-publications-scraper/sp" |
| 48 | + ls -la |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | +
|
| 52 | + - name: Install scraper dependencies |
| 53 | + working-directory: ${{ env.SCRAPER_DIR }} |
| 54 | + run: | |
| 55 | + chmod +x ./sp |
| 56 | + ./sp i |
| 57 | +
|
| 58 | + - name: Run scraper |
| 59 | + working-directory: ${{ env.SCRAPER_DIR }} |
| 60 | + env: |
| 61 | + VENUE_SHORT_LLM_API_KEY: ${{ secrets.VENUE_SHORT_LLM_API_KEY }} |
| 62 | + run: | |
| 63 | + CONFIG_FILE="config.github.json" |
| 64 | + if [ ! -f "$CONFIG_FILE" ]; then |
| 65 | + CONFIG_FILE="config.json" |
| 66 | + fi |
| 67 | +
|
| 68 | + if [ ! -f "$CONFIG_FILE" ]; then |
| 69 | + echo "No config file found in $PWD" |
| 70 | + ls -la |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | +
|
| 74 | + CI_CONFIG_FILE="config.ci.json" |
| 75 | + python - <<'PY' |
| 76 | + import json |
| 77 | +
|
| 78 | + source_file = "config.github.json" |
| 79 | + try: |
| 80 | + with open(source_file, "r", encoding="utf-8") as f: |
| 81 | + cfg = json.load(f) |
| 82 | + except FileNotFoundError: |
| 83 | + source_file = "config.json" |
| 84 | + with open(source_file, "r", encoding="utf-8") as f: |
| 85 | + cfg = json.load(f) |
| 86 | +
|
| 87 | + cfg["existing_js_path"] = "../collection/auto-collected/auto_collected.js" |
| 88 | +
|
| 89 | + with open("config.ci.json", "w", encoding="utf-8") as f: |
| 90 | + json.dump(cfg, f, ensure_ascii=False, indent=2) |
| 91 | +
|
| 92 | + print(f"Prepared CI config from: {source_file}") |
| 93 | + PY |
| 94 | +
|
| 95 | + echo "Using config: $CI_CONFIG_FILE" |
| 96 | + ./sp --config "$CI_CONFIG_FILE" |
| 97 | +
|
| 98 | +
|
| 99 | +
|
| 100 | + - name: Check for changes to commit |
| 101 | + id: check_changes |
| 102 | + run: | |
| 103 | + git add -A |
| 104 | + if git diff --cached --quiet; then |
| 105 | + echo "changes_detected=false" >> $GITHUB_OUTPUT |
| 106 | + echo "No changes to commit, skipping PR." |
| 107 | + exit 0 |
| 108 | + else |
| 109 | + echo "changes_detected=true" >> $GITHUB_OUTPUT |
| 110 | + fi |
| 111 | +
|
| 112 | + - name: Create pull request for updates |
| 113 | + if: steps.check_changes.outputs.changes_detected == 'true' |
| 114 | + uses: peter-evans/create-pull-request@v7 |
| 115 | + with: |
| 116 | + commit-message: "chore: auto update publications" |
| 117 | + branch: "chore/auto-scrape-updates" |
| 118 | + delete-branch: true |
| 119 | + title: "chore: auto update publications" |
| 120 | + body: | |
| 121 | + This PR is automatically generated by the Auto Scrape workflow. |
| 122 | +
|
| 123 | + Changes include: |
| 124 | + - refreshed auto-collected publications |
| 125 | + - updated bundled JSON assets |
| 126 | + labels: | |
| 127 | + automation |
| 128 | + publications |
0 commit comments