diff --git a/.github/workflows/get-metrics.py b/.github/workflows/get-metrics.py index c8123e57..10b3dfbc 100644 --- a/.github/workflows/get-metrics.py +++ b/.github/workflows/get-metrics.py @@ -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) @@ -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. @@ -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') diff --git a/.github/workflows/nightly-build.yaml b/.github/workflows/nightly-build.yaml index 620234a6..f2ab7753 100644 --- a/.github/workflows/nightly-build.yaml +++ b/.github/workflows/nightly-build.yaml @@ -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: @@ -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' diff --git a/.github/workflows/publish-site.yaml b/.github/workflows/publish-site.yaml index d342d19f..af2939e5 100644 --- a/.github/workflows/publish-site.yaml +++ b/.github/workflows/publish-site.yaml @@ -6,6 +6,8 @@ on: branches: - main workflow_dispatch: + schedule: + - cron: '0 0 * * 1' # Weekly on Monday jobs: automate-metrics: @@ -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 diff --git a/.github/workflows/trigger-book-build.yaml b/.github/workflows/trigger-book-build.yaml new file mode 100644 index 00000000..c4dad427 --- /dev/null +++ b/.github/workflows/trigger-book-build.yaml @@ -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 diff --git a/.github/workflows/trigger-preview.yaml b/.github/workflows/trigger-preview.yaml index fcd9167b..f914d8b2 100644 --- a/.github/workflows/trigger-preview.yaml +++ b/.github/workflows/trigger-preview.yaml @@ -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' diff --git a/.gitignore b/.gitignore index 4fb65167..fdf3a8eb 100644 --- a/.gitignore +++ b/.gitignore @@ -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