Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8f1e474

Browse files
authoredMar 21, 2024
Merge pull request #129 from jukent/recovery-branch
Recovery branch
2 parents 935e1d3 + 2f8e5da commit 8f1e474

File tree

6 files changed

+47
-46
lines changed

6 files changed

+47
-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

+23-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,15 +25,35 @@ jobs:
2325
2426
python .github/workflows/get-metrics.py
2527
python .github/workflows/write-metrics-md.py
28+
- name: Zip the repo
29+
run: |
30+
set -x
31+
set -e
32+
if [ -f repo.zip ]; then
33+
rm -rf repo.zip
34+
fi
35+
zip -r repo.zip .
2636
27-
build:
37+
upload-zip:
2838
needs: automate-metrics
39+
runs-on: macos-latest
40+
steps:
41+
- name: Upload artifact
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: 'repo-w-metrics'
45+
path: 'repo.zip'
46+
47+
build:
48+
needs: upload-zip
2949
uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
3050
with:
3151
environment_file: 'environment.yml'
3252
environment_name: pythia
3353
path_to_notebooks: 'portal'
3454
build_command: 'make -j4 html'
55+
build_from_code_artifact: 'true'
56+
code_artifact_name: 'repo-w-metrics'
3557

3658
deploy:
3759
needs: build
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: trigger-book-build
2+
on:
3+
workflow_call:
4+
inputs:
5+
code_artifact_name:
6+
description: 'Artifact of the repository after automate-metrics has run.'
7+
required: true
8+
default: 'repo-zip'
9+
type: string
10+
11+
jobs:
12+
build:
13+
uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
14+
with:
15+
environment_name: pythia-book-dev
16+
artifact_name: book-zip-${{ github.event.number }}
17+
code_artifact_name: inputs.code_artifact_name
18+
# Other input options are possible, see ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml

‎.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-viast-pythia-*.json

0 commit comments

Comments
 (0)
Please sign in to comment.