Skip to content

Update IBM Courses and Match with Credly Badges #85

Update IBM Courses and Match with Credly Badges

Update IBM Courses and Match with Credly Badges #85

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 "[email protected]"
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/[email protected]
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()}.'
})