Skip to content

Commit 367d802

Browse files
jukenterogluorhan
andauthored
Artifact Passing from Automate-Metrics to Build-Book (#415)
* first pass at artifact passing * missed one * pass 2 * revert changes to nightly-build (to not deploy or get metrics), and schedule publish weekly * rename build step * reorder * new placeholder code * edit colorbar width, one more pass at publish-site metrics * does download of artifact happen inside build action? * revert changes to automate metrics step * fix zip job * oops indent * zip needs runs on, but then will it lose the metrics files? * add zip step * rename * add automate metrics back to trigger-preview * make strings * placeholder triggerbookbuild.yaml file * fix inputs * rm curly brackets * trigger_workflow input to book-build * comment out new input * no ! # just # * rm trigger-book-build * fix upload path * remove comment to use new build-book input * just try a full path for trigger_workflow * rm full path * use soon to be new workflow_conclusion as empty, rather than default to success * Update .gitignore Co-authored-by: Orhan Eroglu <[email protected]> --------- Co-authored-by: Orhan Eroglu <[email protected]>
1 parent 935e1d3 commit 367d802

File tree

5 files changed

+17
-46
lines changed

5 files changed

+17
-46
lines changed

.github/workflows/get-metrics.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
FOUNDATIONS_ID = '281776420'
1818
COOKBOOKS_ID = '324070631'
1919

20-
2120
# Access Secrets
2221
PRIVATE_KEY_ID = os.environ.get('PRIVATE_KEY_ID')
2322
# Ensure GH secrets doesn't intrudce extra '\' new line characters (related to '\' being an escape character)
@@ -56,6 +55,8 @@ def _format_rounding(value):
5655
return f'{round(value / 1000, 1):.1f}K'
5756

5857

58+
# The rest of this file alternates between functions for requesting information from Google Analytics
59+
# And functions that use that request image to form either a .json or a .png file to be used in write-metrics-md.py
5960
def _run_total_users_report(property_id):
6061
"""
6162
Function for requesting cumulative active users from a project since project start.
@@ -289,7 +290,7 @@ def plot_usersXcountry(FOUNDATIONS_ID):
289290
)
290291

291292
# Add colorbar
292-
cax = fig.add_axes([0.1, -0.015, 0.67, 0.03])
293+
cax = fig.add_axes([0.05, -0.015, 0.7, 0.03]) # [x0, y0, width, height]
293294
cbar = fig.colorbar(mappable=mappable, cax=cax, spacing='uniform', orientation='horizontal', extend='min')
294295
cbar.set_label('Unique Users')
295296

.github/workflows/nightly-build.yaml

-24
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,7 @@ on:
66
- cron: '0 0 * * *' # Daily “At 00:00”
77

88
jobs:
9-
automate-metrics:
10-
runs-on: macos-latest
11-
steps:
12-
- uses: actions/checkout@v3
13-
- name: Automate Metrics
14-
env:
15-
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
16-
PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
17-
run: |
18-
python -m venv analytics-api
19-
source analytics-api/bin/activate
20-
pip install google-analytics-data cartopy matplotlib
21-
22-
python .github/workflows/get-metrics.py
23-
python .github/workflows/write-metrics-md.py
24-
259
build:
26-
needs: automate-metrics
2710
if: ${{ github.repository_owner == 'ProjectPythia' }}
2811
uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
2912
with:
@@ -37,10 +20,3 @@ jobs:
3720
uses: ./.github/workflows/sphinx-link-checker.yaml
3821
with:
3922
path_to_source: 'portal'
40-
41-
deploy:
42-
needs: build
43-
uses: ProjectPythia/cookbook-actions/.github/workflows/deploy-book.yaml@main
44-
with:
45-
cname: projectpythia.org
46-
publish_dir: 'portal/_build/html'

.github/workflows/publish-site.yaml

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
branches:
77
- main
88
workflow_dispatch:
9+
schedule:
10+
- cron: '0 0 * * 1' # Weekly on Monday
911

1012
jobs:
1113
automate-metrics:
@@ -23,6 +25,11 @@ jobs:
2325
2426
python .github/workflows/get-metrics.py
2527
python .github/workflows/write-metrics-md.py
28+
- name: Upload zip
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: repo-zip
32+
path: .
2633

2734
build:
2835
needs: automate-metrics
@@ -32,7 +39,10 @@ jobs:
3239
environment_name: pythia
3340
path_to_notebooks: 'portal'
3441
build_command: 'make -j4 html'
35-
42+
build_from_code_artifact: 'true'
43+
code_artifact_name: 'repo-zip'
44+
workflow: ''
45+
workflow_conclusion: ''
3646
deploy:
3747
needs: build
3848
uses: ProjectPythia/cookbook-actions/.github/workflows/deploy-book.yaml@main

.github/workflows/trigger-preview.yaml

+1-17
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,9 @@ on:
88
- completed
99

1010
jobs:
11-
automate-metrics:
12-
runs-on: macos-latest
13-
steps:
14-
- uses: actions/checkout@v3
15-
- name: Automate Metrics
16-
env:
17-
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
18-
PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
19-
run: |
20-
python -m venv analytics-api
21-
source analytics-api/bin/activate
22-
pip install google-analytics-data cartopy matplotlib
23-
24-
python .github/workflows/get-metrics.py
25-
python .github/workflows/write-metrics-md.py
26-
2711
find-pull-request:
28-
needs: automate-metrics
2912
uses: ProjectPythia/cookbook-actions/.github/workflows/find-pull-request.yaml@main
13+
3014
deploy-preview:
3115
needs: find-pull-request
3216
if: github.event.workflow_run.conclusion == 'success'

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,5 @@ resource-gallery-submission-input.json
141141

142142
# Analytics
143143
.github/workflows/analytics-api/
144-
.github/workflows/*.json
145-
.github/workflows/*.png
144+
portal/metrics/*.png
145+
cisl-vast-pythia-*.json

0 commit comments

Comments
 (0)