Update pull_metadata.yml #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a workflow to pull all of the metadata from all of the modules into a single file | |
# each time something is merged to main, this workflow will run and rebuild the metadata file. | |
name: pull_metadata | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
push: | |
branches: "metadata_workflow" | |
paths-ignore: | |
- 'assets/**' | |
- '_for_authors/**' | |
- '_module_templates/**' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow starts with a job called "process_metadata" | |
process_metadata: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
outputs: | |
any_changes: ${{ steps.Process_Metadata.outputs.any_changes }} | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
# Runs a set of commands using the runners shell | |
- name: Process_Metadata | |
run: | | |
bash .github/scripts/process_metadata.sh | |
# Check if any changes were made to the python file | |
changes=$(git diff assets/metadata/module_data.py | wc -l) | |
#echo $changes | |
any_changes=$([ $changes -gt 0 ] && echo "true" || echo "false") | |
echo the any_changes variable is now $any_changes | |
echo "any_changes=$any_changes" >> $GITHUB_OUTPUT | |
# If the processed metadata has changed at all, then we update the files: | |
update_data_files: | |
runs-on: ubuntu-latest | |
needs: [ process_metadata ] | |
if: needs.process_metadata.outputs.any_changes == 0 | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v4 | |
with: | |
# Semantic version range syntax or exact version of a Python version | |
python-version: '3.x' | |
- name: Install Python dependencies | |
run: python -m pip install --upgrade pip pandas | |
- name: Create csv from python file | |
run: | | |
python assets/metadata/module_data.py | |
- name: Commit newly updated files | |
run: | |
git config --local user.name actions-user | |
git config --local user.email "[email protected]" | |
git checkout metadata_workflow | |
git fetch | |
git add assets/metadata/module_data.py | |
git add assets/metadata/module_data.csv | |
git commit -am "update metadata records" | |
git push origin metadata_workflow | |