Skip to content

Update pull_metadata.yml #46

Update pull_metadata.yml

Update pull_metadata.yml #46

Workflow file for this run

# 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_change: ${{ 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_change=$any_changes" >> $GITHUB_OUTPUT
# debugging the output relationship
debugging:
runs-on: ubuntu-latest
needs: [ process_metadata ]
#if: needs.process_metadata.outputs.any_changes == true
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- env:
any_changes: ${{needs.process_metadata.outputs.any_change}}
run: echo the any_changes variable is $any_changes
# 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 == true
# 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