Fix versions #7
Workflow file for this run
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: Push versions.json | |
on: | |
push: | |
branches: | |
- "**" | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
jobs: | |
update-doc-versions: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- uses: actions/setup-python@v4 | |
- name: Generate versions.json | |
shell: python3 {0} | |
run: | | |
import json | |
from pathlib import Path | |
cwd = Path.cwd() | |
versions = sorted((item.name for item in cwd.iterdir() | |
if item.is_dir() and not item.name.startswith('.')), | |
reverse=True) | |
target_file = 'versions.json' | |
with target_file.open('w') as f: | |
json.dump(versions, f) | |
- name: Commit versions.json | |
shell: bash | |
run: | | |
# Commit versions.json and squash it with previous commit | |
git config user.name "Actions" | |
git config user.email "actions@github.com" | |
git add versions.json | |
git commit --amend --no-edit | |
git push origin gh-pages |