Skip to content

Commit

Permalink
Merge pull request #129 from jukent/recovery-branch
Browse files Browse the repository at this point in the history
Recovery branch
  • Loading branch information
jukent authored Mar 21, 2024
2 parents 935e1d3 + 2f8e5da commit 8f1e474
Show file tree
Hide file tree
Showing 6 changed files with 47 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'
24 changes: 23 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,15 +25,35 @@ jobs:
python .github/workflows/get-metrics.py
python .github/workflows/write-metrics-md.py
- name: Zip the repo
run: |
set -x
set -e
if [ -f repo.zip ]; then
rm -rf repo.zip
fi
zip -r repo.zip .
build:
upload-zip:
needs: automate-metrics
runs-on: macos-latest
steps:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: 'repo-w-metrics'
path: 'repo.zip'

build:
needs: upload-zip
uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
with:
environment_file: 'environment.yml'
environment_name: pythia
path_to_notebooks: 'portal'
build_command: 'make -j4 html'
build_from_code_artifact: 'true'
code_artifact_name: 'repo-w-metrics'

deploy:
needs: build
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/trigger-book-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: trigger-book-build
on:
workflow_call:
inputs:
code_artifact_name:
description: 'Artifact of the repository after automate-metrics has run.'
required: true
default: 'repo-zip'
type: string

jobs:
build:
uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
with:
environment_name: pythia-book-dev
artifact_name: book-zip-${{ github.event.number }}
code_artifact_name: inputs.code_artifact_name
# Other input options are possible, see ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml
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-viast-pythia-*.json

0 comments on commit 8f1e474

Please sign in to comment.