|
| 1 | +name: docs |
| 2 | + |
| 3 | +on: |
| 4 | + create: |
| 5 | + tags: |
| 6 | + # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet |
| 7 | + - b[0-9][0-9][0-9] |
| 8 | + - publish-docs* |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +jobs: |
| 14 | + decompile: |
| 15 | + runs-on: windows-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v2 |
| 19 | + |
| 20 | + - name: Set up Python |
| 21 | + uses: actions/setup-python@v2 |
| 22 | + with: |
| 23 | + python-version: '3.9' |
| 24 | + |
| 25 | + - name: Install latest release |
| 26 | + run: pip install --user --upgrade pywin32 |
| 27 | + |
| 28 | + - name: Set Python user site directory |
| 29 | + run: python -c "import os,site;open(os.environ['GITHUB_ENV'], 'a').write(f'USER_DIR={site.USER_SITE}\n')" |
| 30 | + |
| 31 | + - name: Decompile shipped help file |
| 32 | + run: hh -decompile site ${env:USER_DIR}\PyWin32.chm |
| 33 | + |
| 34 | + - name: Rename root HTML file |
| 35 | + run: mv site\PyWin32.HTML site\index.html |
| 36 | + |
| 37 | + # Compress first to avoid slowly uploading thousands of individual files |
| 38 | + - name: Create archive |
| 39 | + run: python -m zipfile -c site.zip site |
| 40 | + |
| 41 | + - uses: actions/upload-artifact@v2 |
| 42 | + with: |
| 43 | + name: documentation |
| 44 | + path: site.zip |
| 45 | + |
| 46 | + publish: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + needs: |
| 49 | + - decompile |
| 50 | + |
| 51 | + # Only publish tags |
| 52 | + if: github.event_name == 'create' && github.event.ref_type == 'tag' |
| 53 | + |
| 54 | + steps: |
| 55 | + - uses: actions/download-artifact@v2 |
| 56 | + with: |
| 57 | + name: documentation |
| 58 | + |
| 59 | + - name: Unpack archive |
| 60 | + run: python -m zipfile -e site.zip . |
| 61 | + |
| 62 | + - uses: peaceiris/actions-gh-pages@v3 |
| 63 | + with: |
| 64 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + publish_dir: site |
| 66 | + commit_message: ${{ github.event.head_commit.message }} |
| 67 | + # Write .nojekyll at the root, see: |
| 68 | + # https://help.github.com/en/github/working-with-github-pages/about-github-pages#static-site-generators |
| 69 | + enable_jekyll: false |
| 70 | + # Only deploy if there were changes |
| 71 | + allow_empty_commit: false |
0 commit comments