Scrape Instagram and Store Events #105
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: Scrape Instagram and Store Events | |
| on: | |
| schedule: | |
| - cron: '0 12 * * *' # 7:00am EST = 12:00 UTC | |
| workflow_dispatch: # Optional manual trigger | |
| jobs: | |
| instagram_feed: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| env: | |
| SUPABASE_DB_URL: ${{ secrets.SUPABASE_DB_URL }} | |
| USERNAME: ${{ secrets.USERNAME }} | |
| PASSWORD: ${{ secrets.PASSWORD }} | |
| SESSIONID: ${{ secrets.SESSIONID }} | |
| CSRFTOKEN: ${{ secrets.CSRFTOKEN }} | |
| DS_USER_ID: ${{ secrets.DS_USER_ID }} | |
| IG_DID: ${{ secrets.IG_DID }} | |
| MID: ${{ secrets.MID }} | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| DOC_ID: ${{ secrets.DOC_ID }} | |
| USER_AGENT: ${{ secrets.USER_AGENT }} | |
| X_IG_APP_ID: ${{ secrets.X_IG_APP_ID }} | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }} | |
| AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('backend/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install build tools | |
| run: pip install --upgrade pip setuptools wheel | |
| - name: Install dependencies | |
| working-directory: backend | |
| run: pip install -r requirements.txt | |
| - name: Create logs directory | |
| working-directory: backend/scraping | |
| run: mkdir -p logs | |
| # - name: Run scraper | |
| # working-directory: backend/scraping | |
| # run: | | |
| # python -u instagram_feed.py 2>&1 | tee logs/scraping.log | |
| # continue-on-error: false | |
| - name: Generate static events file | |
| id: generate_static | |
| working-directory: backend/scraping | |
| run: python get_static_events.py | |
| - name: Commit and push changes | |
| if: steps.generate_static.outcome == 'success' | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add frontend/src/data/staticEvents.ts | |
| git commit -m "chore: update static events from DB" || echo "No changes to commit" | |
| git push | |
| - name: Upload logs as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: scraping-logs-${{ github.run_number }} | |
| path: | | |
| backend/scraping/logs/ | |
| backend/scraping/*.log | |
| backend/scraping/*.csv | |
| retention-days: 30 |