Skip to content

Commit 58e1cb1

Browse files
committed
Add Github Action to automate updating 2024-2025 PEY dashboard data
1 parent e4f3ed1 commit 58e1cb1

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Check and Update 2024-2025 PEY Job Postings
2+
3+
on:
4+
schedule:
5+
- cron: '*/30 * * * *' # Runs every 30 minutes
6+
workflow_dispatch:
7+
8+
jobs:
9+
parse-and-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout the 2024 branch
13+
uses: actions/checkout@v3
14+
with:
15+
ref: 2024
16+
17+
- name: Clone the 2024-25 PEY archive repo (shallow clone)
18+
run: git clone --depth 1 https://github.com/CanadianDesk/2024-25-pey-archive pey-archive
19+
20+
- name: Clone the blog repo
21+
run: git clone https://github.com/sadmanca/blog blog-repo
22+
23+
- name: Checkout master branch in blog repo
24+
run: |
25+
cd blog-repo
26+
git checkout master
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: '3.x'
32+
33+
- name: Cache pip dependencies
34+
uses: actions/cache@v3
35+
with:
36+
path: ~/.cache/pip
37+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
38+
restore-keys: |
39+
${{ runner.os }}-pip-
40+
41+
- name: Install dependencies
42+
run: pip install -r requirements.txt
43+
44+
- name: Configure git for commit
45+
run: |
46+
git config --global user.name "github-actions[bot]"
47+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
48+
49+
- name: Delete existing JSON file
50+
run: |
51+
rm -f blog-repo/data/PEYJobPosting2024.json
52+
53+
- name: Run the parsing script
54+
run: python parse_folder_to_db.py -v -d "pey-archive/postings" -o "blog-repo/data/PEYJobPosting2024.json"
55+
56+
- name: Commit the new JSON file with timestamp
57+
id: commit_changes
58+
run: |
59+
cd blog-repo
60+
timestamp=$(date)
61+
git add data/PEYJobPosting2024.json
62+
git commit -m "Add updated PEY job postings data - $timestamp" || echo "No changes to commit"
63+
continue-on-error: true
64+
65+
- name: Set up authentication for pushing changes
66+
if: steps.commit_changes.outcome == 'success' && steps.commit_changes.conclusion != 'skipped'
67+
run: |
68+
cd blog-repo
69+
git remote set-url origin https://x-access-token:${{ secrets.GH_BLOG_TOKEN }}@github.com/sadmanca/blog.git
70+
71+
- name: Push changes to the blog repo
72+
if: steps.commit_changes.outcome == 'success' && steps.commit_changes.conclusion != 'skipped'
73+
run: |
74+
cd blog-repo
75+
git push -u origin master
76+
77+
- name: Send notification via curl
78+
if: steps.commit_changes.outcome == 'success' && steps.commit_changes.conclusion != 'skipped'
79+
run: |
80+
current_time=$(date)
81+
curl -d "$current_time" ntfy.sh/sadmanca-uoft-pey-coop-jobs-dashboard-2024-2025

0 commit comments

Comments
 (0)