-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (67 loc) · 2.53 KB
/
update_courses.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Update IBM Courses and Match with Credly Badges
on:
schedule:
- cron: '0 0 * * *' # This will run the workflow daily at midnight UTC.
workflow_dispatch: # This allows you to manually trigger the workflow from the GitHub UI.
jobs:
fetch_and_process_data:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
path: 'ibm-course-catalog' # Specify the desired path for cloning the repository
- name: Fetch IBM Courses
run: |
retries=3
until_failure=0
for ((i=0; i<retries; i++)); do
curl -o course_feed.json https://www.ibm.com/training/files/GTPjson/CourseFeed_Global.json && break || sleep 10
until_failure=$((until_failure+1))
if [ $until_failure -eq 3 ]; then
exit 1
fi
done
- name: Fetch Credly Badges
env:
CREDLY_TOKEN: ${{ secrets.CREDLY_TOKEN }}
run: |
retries=3
until_failure=0
for ((i=0; i<retries; i++)); do
curl -u "$CREDLY_TOKEN:" -X GET "https://api.credly.com/v1/badges" -H "Accept: application/json" -o badges.json && break || sleep 10
until_failure=$((until_failure+1))
if [ $until_failure -eq 3 ]; then
exit 1
fi
done
- name: Match Courses to Badges
run: |
retries=3
until_failure=0
for ((i=0; i<retries; i++)); do
python ibm-course-catalog/match_courses_to_badges.py && break || sleep 10
until_failure=$((until_failure+1))
if [ $until_failure -eq 3 ]; then
exit 1
fi
done
- name: Commit and Push Updates
if: success() && github.event_name != 'schedule'
run: |
cd ibm-course-catalog
git config --global user.email "raydo@skunkworks.africa"
git config --global user.name "burnt-exe"
git add -A
git diff-index --quiet HEAD || git commit -m "Updated IBM courses and matched badges" && git push
- name: Notify Update
if: success() && github.event_name != 'schedule'
uses: actions/github-script@0.9.0
with:
script: |
github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'IBM Courses and Badges Update',
body: 'IBM courses and matched badges were updated on ${new Date().toISOString()}.'
})