|
| 1 | +name: Scrape |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + workflow_dispatch: |
| 6 | + schedule: |
| 7 | + # Daily at 6:23 AM UTC |
| 8 | + - cron: '23 6 * * *' |
| 9 | + # For hourly at 42 minutes past the hour: '42 * * * *' |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + setup: # Delete this joh after it first runs if you like |
| 16 | + runs-on: ubuntu-latest |
| 17 | + if: ${{ !github.event.repository.is_template }} |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + if: ${{ always() && !hashFiles('scrape.sh') }} |
| 21 | + - name: Create scrape.sh (using github context) |
| 22 | + if: ${{ always() && !hashFiles('scrape.sh') }} |
| 23 | + run: | |
| 24 | + if [ ! -f "scrape.sh" ]; then |
| 25 | + echo '#!/bin/bash' > scrape.sh |
| 26 | + if [[ "$REPO_DESC" == http://* ]] || [[ "$REPO_DESC" == https://* ]]; then |
| 27 | + echo "wget $REPO_DESC" >> scrape.sh |
| 28 | + else |
| 29 | + echo '# wget https://www.example.com/' >> scrape.sh |
| 30 | + fi |
| 31 | + chmod +x scrape.sh |
| 32 | + fi |
| 33 | + # Now push that to git |
| 34 | + git config user.name "Automated" |
| 35 | + git config user.email "[email protected]" |
| 36 | + git add scrape.sh |
| 37 | + timestamp=$(date -u) |
| 38 | + git commit -m "${timestamp}" || exit 0 |
| 39 | + git pull --rebase |
| 40 | + git push |
| 41 | + env: |
| 42 | + REPO_DESC: ${{ github.event.repository.description }} |
| 43 | + |
| 44 | + scrape: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + if: ${{ !github.event.repository.is_template }} |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + # Uncomment to use Python: |
| 50 | + # - name: Set up Python 3.13 |
| 51 | + # uses: actions/setup-python@v5 |
| 52 | + # with: |
| 53 | + # python-version: "3.13" |
| 54 | + # cache: "pip" |
| 55 | + # - name: Install dependencies |
| 56 | + # run: | |
| 57 | + # pip install -r requirements.txt |
| 58 | + # Uncomment to use Playwright via shot-scraper (put shot-scraper in requirements.txt): |
| 59 | + # - name: Cache Playwright browsers |
| 60 | + # uses: actions/cache@v4 |
| 61 | + # with: |
| 62 | + # path: ~/.cache/ms-playwright/ |
| 63 | + # key: ${{ runner.os }}-browsers |
| 64 | + # - name: Install Playwright dependencies |
| 65 | + # run: | |
| 66 | + # shot-scraper install |
| 67 | + - name: Run the scraper |
| 68 | + run: | |
| 69 | + if [ ! -x scrape.sh ]; then |
| 70 | + chmod 755 scrape.sh |
| 71 | + fi |
| 72 | + ./scrape.sh |
| 73 | + - name: Commit and push |
| 74 | + run: |- |
| 75 | + git config user.name "Automated" |
| 76 | + git config user.email "[email protected]" |
| 77 | + git add -A |
| 78 | + timestamp=$(date -u) |
| 79 | + git commit -m "${timestamp}" || exit 0 |
| 80 | + git pull --rebase |
| 81 | + git push |
0 commit comments