Skip to content

save-daily-metrics

save-daily-metrics #72

name: save-daily-metrics
on:
workflow_dispatch:
schedule:
# Run every day at 8:00 PM UTC
# https://crontab.guru/#0_20_*_*_*
- cron: "0 20 * * *"
jobs:
save-daily-metrics:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up conda environment for testing
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
cache-environment: true
condarc: |
channels:
- conda-forge
channel_priority: strict
- name: Log conda environnment information
run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- name: Authenticate gcloud
id: gcloud-auth
continue-on-error: true
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_USAGE_METRICS_ARCHIVER_KEY }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
with:
version: ">= 363.0.0"
- shell: bash -l {0}
name: Save Github Metrics
id: github
env:
API_TOKEN_GITHUB: ${{ secrets.USAGE_STATS_ACCESS_TOKEN }}
run: |
python src/usage_metrics/scripts/save_github_metrics.py
- shell: bash -l {0}
name: Save Kaggle Metrics
id: kaggle
# Run even if prior metric saving fails
if: "!cancelled()"
env:
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}
KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
run: |
python src/usage_metrics/scripts/save_kaggle_metrics.py
- shell: bash -l {0}
name: Save Zenodo Metrics
id: zenodo
# Run even if prior metric saving fails
if: "!cancelled()"
run: |
python src/usage_metrics/scripts/save_zenodo_metrics.py
- name: Inform the Codemonkeys
uses: 8398a7/action-slack@v3
with:
status: custom
fields: workflow,job,commit,repo,ref,author,took
custom_payload: |
{
username: 'action-slack',
icon_emoji: ':octocat:',
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `${process.env.AS_WORKFLOW}\n${process.env.AS_JOB} (${process.env.AS_COMMIT}) of ${process.env.AS_REPO}@${process.env.AS_REF} by ${process.env.AS_AUTHOR} ${{ job.status }} in ${process.env.AS_TOOK}`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
MATRIX_CONTEXT: ${{ toJson(matrix) }} # required
if: always() # Pick up events even if the job fails or is canceled.