Check and Update 2024-2025 PEY Job Postings #9
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 and Commit PEY Job Postings | |
| on: | |
| schedule: | |
| - cron: '*/5 * * * *' # Runs every 5 minutes | |
| workflow_dispatch: | |
| jobs: | |
| parse-and-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the 2024 branch | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: 2024 | |
| - name: Clone the 2024-25 PEY archive repo (shallow clone) | |
| run: git clone --depth 1 https://github.com/sadmanca/2024-25-pey-archive pey-archive | |
| - name: Clone the blog repo | |
| run: | | |
| git clone https://github.com/sadmanca/blog blog-repo | |
| - name: Checkout pey-2024-test branch in blog repo | |
| run: | | |
| cd blog-repo | |
| git checkout pey-2024-test | |
| - name: Check for new commits | |
| id: check_commits | |
| run: | | |
| cd pey-archive | |
| git fetch origin main # Fetch the latest changes | |
| NEW_COMMITS=$(git rev-list HEAD...origin/main --count) | |
| echo "new_commits=$NEW_COMMITS" >> $GITHUB_ENV | |
| - name: Skip if no new commits | |
| if: env.new_commits == '0' | |
| run: echo "No new commits found. Skipping the workflow." | |
| - name: Set up Python | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Cache pip dependencies | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| run: pip install -r requirements.txt | |
| - name: Delete existing JSON file | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| run: | | |
| rm -f blog-repo/data/PEYJobPosting2024.json | |
| - name: Run the parsing script | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| run: python parse_folder_to_db.py -v -d "pey-archive/postings" -o "blog-repo/data/PEYJobPosting2024.json" | |
| - name: Configure git for commit | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit the new JSON file with timestamp | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| run: | | |
| cd blog-repo | |
| timestamp=$(date) | |
| git add data/PEYJobPosting2024.json | |
| git commit -m "Add updated PEY job postings data - $timestamp" | |
| - name: View git log | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| run: | | |
| cd blog-repo | |
| git log --oneline | |
| - name: Set up authentication for pushing changes | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| run: | | |
| cd blog-repo | |
| git remote set-url origin https://x-access-token:${{ secrets.GH_BLOG_TOKEN }}@github.com/sadmanca/blog.git | |
| - name: Push changes to the blog repo | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| run: | | |
| cd blog-repo | |
| git push -u origin pey-2024-test | |
| - name: Send notification via curl | |
| if: env.new_commits != '0' # Only run if there are new commits | |
| run: | | |
| current_time=$(date) | |
| curl -d "$current_time" ntfy.sh/sadmanca-uoft-pey-coop-jobs-dashboard-2024-2025 |