Update build time diagrams #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Update build time diagrams" | |
on: | |
schedule: | |
# At 23:00 | |
# See https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule | |
- cron: "0 23 * * *" | |
workflow_dispatch: | |
inputs: | |
get_stats: | |
description: 'Get stats' | |
default: true | |
required: false | |
type: boolean | |
create_diagrams: | |
description: 'Create diagrams' | |
default: true | |
required: false | |
type: boolean | |
jobs: | |
update-build-time-diagrams: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Copr config file | |
env: | |
# You need to have those secrets in your repo. | |
# See also: https://copr.fedorainfracloud.org/api/. | |
COPR_CONFIG_FILE: ${{ secrets.COPR_CONFIG }} | |
run: | | |
mkdir -p ~/.config | |
printf "$COPR_CONFIG_FILE" > ~/.config/copr | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Checkout main branch | |
uses: actions/checkout@v3 | |
with: | |
ref: 'main' | |
path: 'main' | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v3 | |
with: | |
ref: 'gh-pages' | |
path: 'gh-pages' | |
- name: "Check for cached dependencies" | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r main/build-stats/requirements.txt | |
- name: Setup git config | |
run: | | |
git config --global user.name "Github Actions Bot" | |
git config --global user.email "<>" | |
- name: "Update build stats and re-generate diagrams" | |
shell: bash -e {0} | |
run: | | |
if ${{ inputs.get_stats }}; then | |
main/build-stats/get-build-stats.py | tee -a gh-pages/build-stats.csv | |
git -C gh-pages add build-stats.csv | |
fi | |
if ${{ inputs.create_diagrams }}; then | |
main/build-stats/create-diagrams.py --datafile gh-pages/build-stats.csv | |
mv index.html gh-pages/index.html | |
mv fig-*.html gh-pages/ | |
git -C gh-pages add index.html fig-*.html | |
fi | |
if [[ ${{ inputs.get_stats }} || ${{ inputs.create_diagrams }} ]]; then | |
cd gh-pages | |
git commit -m "Automatically update stats build stats" | |
git push origin HEAD:gh-pages | |
fi |