Skip to content

Merge pull request #127 from kafitzgerald/geocat_intern_updates #17

Merge pull request #127 from kafitzgerald/geocat_intern_updates

Merge pull request #127 from kafitzgerald/geocat_intern_updates #17

name: Update Metrics
on:
push:
branches:
- main
paths:
- 'data/publications.yml'
- 'data/presentations.yml'
- 'data/packages.yml'
- 'data/siparcs.yml'
jobs:
update_metrics:
runs-on: 'ubuntu-20.04'
steps:
- uses: actions/checkout@v3
with:
ref: 'main'
- name: Install dependencies
run: |
python -m pip install pip --upgrade
python -m pip install ruamel.yaml pre-commit
- name: Update publications metrics
shell: python
run: |
from ruamel.yaml import YAML
yaml = YAML()
metrics_file = 'data/metrics.yml'
publications_file = 'data/publications.yml'
presentations_file = 'data/presentations.yml'
packages_file = 'data/packages.yml'
siparcs_file = 'data/siparcs.yml'
with open(publications_file) as f:
publications_dict = yaml.load(f)
publications = len(publications_dict['items'])
with open(presentations_file) as f:
presentations_dict = yaml.load(f)
presentations = len(presentations_dict['items'])
with open(packages_file) as f:
packages_dict = yaml.load(f)
packages = len(packages_dict['items'])
with open(siparcs_file) as f:
siparcs_dict = yaml.load(f)
interns = len(siparcs_dict['items'])
with open(metrics_file, 'r+') as f:
metrics_dict = yaml.load(f)
metrics_dict['counter_item'][1]["number"] = publications
metrics_dict['counter_item'][2]["number"] = presentations
metrics_dict['counter_item'][3]["number"] = packages
metrics_dict['counter_item'][4]["number"] = interns
with open(metrics_file, 'w') as f:
yaml.dump(metrics_dict, f)
- name: Commit and push changes
run: |
git config --global user.name '${{ github.actor }}'
git config --global user.email '<${{ github.actor }}@users.noreply.github.com>'
git remote set-url origin https://x-access-token:${{ secrets.VAST_METRICS }}@github.com/NCAR/vast
git add data/metrics.yml
git commit --allow-empty -m "Update metrics.yml from changes to data"
git push -u origin HEAD