deploy #3514
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: deploy | |
on: | |
push: | |
branches: | |
- deploy/site | |
# trigger after a scheduled run of the benchmarks | |
workflow_run: | |
workflows: [benchmark] | |
branches: [main] | |
types: [completed] | |
jobs: | |
deploy: | |
runs-on: ubuntu-22.04 | |
permissions: | |
actions: read | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- uses: actions/cache@v4 | |
name: Configure pip caching | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip | |
- name: Cache Playwright browsers | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/ms-playwright/ | |
key: ${{ runner.os }}-playwright | |
- name: prereqs | |
run: | | |
pip install --disable-pip-version-check sqlite-utils csv2md shot-scraper | |
shot-scraper install | |
- name: average stats | |
run: | | |
./bin/generate_average_stats.sh | |
csv2md stats.csv >> $GITHUB_STEP_SUMMARY | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
- name: dependencies | |
run: npm ci | |
working-directory: site | |
- name: build site | |
working-directory: site | |
run: | | |
set -ex | |
./csv_to_json.py ../stats.csv > data.json | |
npm run build | |
python -m http.server --directory dist & | |
PID=$! | |
sleep 1 | |
shot-scraper http://localhost:8000 -s '#install-chart' --width 1200 --height 675 --padding 10 -o ogimage.png | |
kill $PID | |
npm run build | |
tar -cf /tmp/dist.tar -C dist . | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
- name: push | |
run: | | |
set -ex | |
git config user.name "GitHub Actions" | |
git config user.email "<>" | |
rm -rf ./* | |
tar -xf /tmp/dist.tar | |
git add -A | |
# If there's nothing new, commit will fail expectedly. | |
# This prevents that from also failing the workflow. | |
git commit -m "gh pages" && git push origin gh-pages || echo "Unable to commit/push" |