Parse RustMaps #34
This file contains hidden or 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: Parse RustMaps | |
| on: | |
| schedule: | |
| - cron: '0 */6 * * *' # каждые 6 часов | |
| workflow_dispatch: # ручной запуск | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| parse-maps: | |
| runs-on: ubuntu-latest | |
| env: | |
| CONCURRENCY: 2 # Уменьшаем количество одновременных запросов | |
| CHUNK: 50 # Уменьшаем размер чанка | |
| NODE_OPTIONS: "--max-old-space-size=2048" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Parse maps (ignore script errors) | |
| id: parse | |
| continue-on-error: true | |
| run: | | |
| # даже при таймаутe или падении npm start шаг вернёт код 0 | |
| timeout 3600s npm start || true | |
| # Всегда создаём файл-индикатор успешного завершения | |
| echo "Script completed at $(date)" > parse-completed.txt | |
| env: | |
| STEAM_KEY: ${{ secrets.STEAM_KEY }} | |
| DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
| - name: Configure Git | |
| if: always() | |
| run: | | |
| git config --global user.name 'GitHub Actions' | |
| git config --global user.email 'actions@github.com' | |
| - name: Add dates.json | |
| if: always() | |
| run: git add dates.json || true | |
| - name: Commit dates.json | |
| if: always() | |
| continue-on-error: true | |
| run: git commit -m "Update dates [skip ci]" || true | |
| - name: Push dates.json | |
| if: always() | |
| continue-on-error: true | |
| run: git push || true | |
| - name: Detect changes in data/maps.json | |
| id: changes | |
| if: always() | |
| run: | | |
| git add data/maps.json || true | |
| if git diff --cached --quiet; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit & push maps.json | |
| if: steps.changes.outputs.changed == 'true' | |
| continue-on-error: true | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git commit -m "🤖 Update rustmaps cache $(date -u '+%Y-%m-%d %H:%M:%S UTC')" || true | |
| git pull --rebase --autostash || true | |
| git push || true | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: rustmaps-cache | |
| path: data/maps.json | |
| retention-days: 30 | |
| # Всегда отмечаем задачу как успешную | |
| - name: Mark job as successful | |
| if: always() | |
| run: exit 0 |