diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index e529e35c5f..cc8b8576d7 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -19,9 +19,47 @@ concurrency: cancel-in-progress: false jobs: + update-reports-and-graphs: + permissions: write-all + name: update reports and graphs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # update stats + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + - name: cache pip + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - run: pip install -r requirements.txt + - run: ./gen_reports.sh + env: + GITHUB_TOKEN: ${{ secrets.METRICS_GITHUB_TOKEN }} + AUGUR_HOST: ${{ vars.AUGUR_HOST }} + - run: ./gen_graphs.sh + env: + GITHUB_TOKEN: ${{ secrets.METRICS_GITHUB_TOKEN }} + AUGUR_HOST: ${{ vars.AUGUR_HOST }} + - run: | + git config user.name 'GitHub Actions' + git config user.email 'actions@users.noreply.github.com' + git add -A + timestamp=$(date -u) + git commit -m "update data: ${timestamp}" || exit 0 + - name: Push to ${{ github.ref_name }} + uses: CasperWA/push-protected@v2 + with: + token: ${{ secrets.METRICS_GITHUB_TOKEN }} + branch: ${{ github.ref_name }} deploy: runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' + needs: update-reports-and-graphs defaults: run: working-directory: ./app @@ -55,4 +93,5 @@ jobs: path: app/dist - name: Deploy to GitHub pages - uses: actions/deploy-pages@v2 \ No newline at end of file + uses: actions/deploy-pages@v2 + \ No newline at end of file diff --git a/gen_graphs.sh b/gen_graphs.sh new file mode 100644 index 0000000000..c62100d6f9 --- /dev/null +++ b/gen_graphs.sh @@ -0,0 +1,4 @@ +#!/bin/bash +pwd +cd scripts +python3 refresh_graphs.py \ No newline at end of file diff --git a/gen_reports.sh b/gen_reports.sh new file mode 100644 index 0000000000..c62d807e6d --- /dev/null +++ b/gen_reports.sh @@ -0,0 +1,4 @@ +#!/bin/bash +pwd +cd scripts +python3 refresh_reports.py \ No newline at end of file diff --git a/scripts/refresh_metrics.py b/scripts/refresh_metrics.py index ce8c8b0ce8..a65d5a0476 100644 --- a/scripts/refresh_metrics.py +++ b/scripts/refresh_metrics.py @@ -5,7 +5,6 @@ import json from fetch_public_metrics import get_all_data, parse_repos_and_orgs_into_objects from fetch_public_metrics import parse_tracked_repos_file, read_previous_metric_data -from gen_graphs import generate_all_graphs_for_repos, generate_all_graphs_for_orgs