-
Notifications
You must be signed in to change notification settings - Fork 5
71 lines (59 loc) · 2.23 KB
/
update-metrics.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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