Skip to content

Update metadata from education_modules repository #68

Update metadata from education_modules repository

Update metadata from education_modules repository #68

# This workflow updates the data in module_data.py once a week.
# It can also be run manually if significant changes to metadata have been made.
name: Update metadata from education_modules repository
on:
schedule:
- cron: '17 3 * * 0'
workflow_dispatch:
jobs:
check_for_changes:
name: Check if the module_data has changed
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.check_if_changed.outputs.changes }}
steps:
- name: Compare module_data files
id: check_if_changed
run: |
wget https://raw.githubusercontent.com/arcus/education_modules/metadata_workflow/assets/metadata/module_data.json -O education_modules_file.json
wget https://raw.githubusercontent.com/arcus/module_discovery/main/assets/education_modules.json -O module_discovery_file.json
changes=$(diff education_modules_file.json module_discovery_file.json | wc -l)
echo "changes=$changes" >> "$GITHUB_OUTPUT"
echo $changes
update_module_data:
name: Update module_data.json
runs-on: ubuntu-latest
needs: check_for_changes
if: needs.check_for_changes.outputs.changes != 0
steps:
- uses: actions/checkout@v3
- name: Download module_data.json from education_modules
run: |
wget https://raw.githubusercontent.com/arcus/education_modules/metadata_workflow/assets/metadata/module_data.json -O assets/education_modules.json
wc assets/education_modules.json
- name: Commit
run: |
git status
git config --local user.name actions-user
git config --local user.email "actions@github.com"
git fetch
git add assets/education_modules.json
git commit -am "update metadata records"
git push origin main