Skip to content

Commit 3f210fa

Browse files
authored
Create update-2024-pey-jobs-blog.yml
1 parent e4f3ed1 commit 3f210fa

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Update PEY 2024-2025 Job Postings Dashboard on Blog
2+
3+
on:
4+
schedule:
5+
- cron: '*/5 * * * *' # Runs every 5 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: |
22+
git clone https://github.com/sadmanca/blog blog-repo
23+
24+
- name: Checkout pey-2024-test branch in blog repo
25+
run: |
26+
cd blog-repo
27+
git checkout pey-2024-test
28+
29+
- name: Check for new commits
30+
id: check_commits
31+
run: |
32+
cd pey-archive
33+
git fetch origin main # Fetch the latest changes
34+
NEW_COMMITS=$(git rev-list HEAD...origin/main --count)
35+
echo "new_commits=$NEW_COMMITS" >> $GITHUB_ENV
36+
37+
- name: Skip if no new commits
38+
if: env.new_commits == '0'
39+
run: echo "No new commits found. Skipping the workflow."
40+
41+
- name: Set up Python
42+
if: env.new_commits != '0' # Only run if there are new commits
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: '3.x'
46+
47+
- name: Cache pip dependencies
48+
if: env.new_commits != '0' # Only run if there are new commits
49+
uses: actions/cache@v3
50+
with:
51+
path: ~/.cache/pip
52+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
53+
restore-keys: |
54+
${{ runner.os }}-pip-
55+
56+
- name: Install dependencies
57+
if: env.new_commits != '0' # Only run if there are new commits
58+
run: pip install -r requirements.txt
59+
60+
- name: Run the parsing script
61+
if: env.new_commits != '0' # Only run if there are new commits
62+
run: python parse_folder_to_db.py -v -d "pey-archive/postings" -o "blog-repo/data/PEYJobPosting2024.json"
63+
64+
- name: Configure git for commit
65+
if: env.new_commits != '0' # Only run if there are new commits
66+
run: |
67+
git config --global user.name "github-actions[bot]"
68+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
69+
70+
- name: Commit the new JSON file with timestamp
71+
if: env.new_commits != '0' # Only run if there are new commits
72+
run: |
73+
cd blog-repo
74+
timestamp=$(date)
75+
git add data/PEYJobPosting2024.json
76+
git commit -m "Add updated PEY job postings data - $timestamp"
77+
78+
- name: View git log
79+
if: env.new_commits != '0' # Only run if there are new commits
80+
run: |
81+
cd blog-repo
82+
git log --oneline
83+
84+
- name: Set up authentication for pushing changes
85+
if: env.new_commits != '0' # Only run if there are new commits
86+
run: |
87+
cd blog-repo
88+
git remote set-url origin https://x-access-token:${{ secrets.GH_BLOG_TOKEN }}@github.com/sadmanca/blog.git
89+
90+
- name: Push changes to the blog repo
91+
if: env.new_commits != '0' # Only run if there are new commits
92+
run: |
93+
cd blog-repo
94+
git push -u origin pey-2024-test
95+
96+
- name: Send notification via curl
97+
if: env.new_commits != '0' # Only run if there are new commits
98+
run: |
99+
current_time=$(date)
100+
curl -d "$current_time" ntfy.sh/sadmanca-uoft-pey-coop-jobs-dashboard-2024-2025

0 commit comments

Comments
 (0)