Skip to content

Commit

Permalink
Artifact Passing from Automate-Metrics to Build-Book (#415)
Browse files Browse the repository at this point in the history
* 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 <32553057+erogluorhan@users.noreply.github.com>

---------

Co-authored-by: Orhan Eroglu <32553057+erogluorhan@users.noreply.github.com>
  • Loading branch information
jukent and erogluorhan authored Mar 25, 2024
1 parent 935e1d3 commit 367d802
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 46 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/get-metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
FOUNDATIONS_ID = '281776420'
COOKBOOKS_ID = '324070631'


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


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

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

Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/nightly-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,7 @@ on:
- cron: '0 0 * * *' # Daily “At 00:00”

jobs:
automate-metrics:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Automate Metrics
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
run: |
python -m venv analytics-api
source analytics-api/bin/activate
pip install google-analytics-data cartopy matplotlib
python .github/workflows/get-metrics.py
python .github/workflows/write-metrics-md.py
build:
needs: automate-metrics
if: ${{ github.repository_owner == 'ProjectPythia' }}
uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
with:
Expand All @@ -37,10 +20,3 @@ jobs:
uses: ./.github/workflows/sphinx-link-checker.yaml
with:
path_to_source: 'portal'

deploy:
needs: build
uses: ProjectPythia/cookbook-actions/.github/workflows/deploy-book.yaml@main
with:
cname: projectpythia.org
publish_dir: 'portal/_build/html'
12 changes: 11 additions & 1 deletion .github/workflows/publish-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' # Weekly on Monday

jobs:
automate-metrics:
Expand All @@ -23,6 +25,11 @@ jobs:
python .github/workflows/get-metrics.py
python .github/workflows/write-metrics-md.py
- name: Upload zip
uses: actions/upload-artifact@v4
with:
name: repo-zip
path: .

build:
needs: automate-metrics
Expand All @@ -32,7 +39,10 @@ jobs:
environment_name: pythia
path_to_notebooks: 'portal'
build_command: 'make -j4 html'

build_from_code_artifact: 'true'
code_artifact_name: 'repo-zip'
workflow: ''
workflow_conclusion: ''
deploy:
needs: build
uses: ProjectPythia/cookbook-actions/.github/workflows/deploy-book.yaml@main
Expand Down
18 changes: 1 addition & 17 deletions .github/workflows/trigger-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,9 @@ on:
- completed

jobs:
automate-metrics:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Automate Metrics
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
run: |
python -m venv analytics-api
source analytics-api/bin/activate
pip install google-analytics-data cartopy matplotlib
python .github/workflows/get-metrics.py
python .github/workflows/write-metrics-md.py
find-pull-request:
needs: automate-metrics
uses: ProjectPythia/cookbook-actions/.github/workflows/find-pull-request.yaml@main

deploy-preview:
needs: find-pull-request
if: github.event.workflow_run.conclusion == 'success'
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,5 @@ resource-gallery-submission-input.json

# Analytics
.github/workflows/analytics-api/
.github/workflows/*.json
.github/workflows/*.png
portal/metrics/*.png
cisl-vast-pythia-*.json

0 comments on commit 367d802

Please sign in to comment.