diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 658d4da3..3e32265a 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -14,17 +14,28 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + ref: gh-pages + - uses: actions/setup-python@v4 - name: Generate versions.json - shell: bash + shell: python3 {0} run: | - mkdir versions_folder - echo ["main", "0.1.19", "0.1.18", "0.1.12", "0.1.11"] > versions_folder/versions.json + 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 = Path('versions.json') + with target_file.open('w') as f: + json.dump(versions, f) - name: Commit versions.json - uses: JamesIves/github-pages-deploy-action@v4 - with: - branch: gh-pages # The branch the action should deploy to. - folder: versions_folder # The folder the action should deploy. - target-folder: / # The folder the action should deploy to. - commit-message: publish documentation - single-commit: true - clean: false + 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