Skip to content

Fixed a buch of things on the website #7

Fixed a buch of things on the website

Fixed a buch of things on the website #7

name: Update Publications Metrics
on:
push:
branches:
- main
paths:
- 'data/publications.yml'
- 'data/realtimeproducts.yml'
- 'data/collaboration.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'
realtimeproducts_file = 'data/realtimeproducts.yml'
collaboration_file = 'data/collaboration.yml'
with open(publications_file) as f:
publications_dict = yaml.load(f)
publications = len(publications_dict['items'])
with open(realtimeproducts_file) as f:
realtimeproducts_dict = yaml.load(f)
realtimeproducts = len(realtimeproducts_dict['items'])
with open(collaboration_file) as f:
collaboration_dict = yaml.load(f)
interns = len(collaboration_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"] = realtimeproducts
metrics_dict['counter_item'][3]["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/miles
git add data/metrics.yml
git commit --allow-empty -m "Update metrics.yml from changes to data"
git push -u origin HEAD