|
| 1 | +on: |
| 2 | + workflow_call: |
| 3 | + inputs: |
| 4 | + site-version: |
| 5 | + required: true |
| 6 | + type: string |
| 7 | + version-alias: |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + default: "" |
| 11 | + branch: |
| 12 | + required: false |
| 13 | + type: string |
| 14 | + default: "gh-pages" |
| 15 | + set-default: |
| 16 | + required: false |
| 17 | + type: boolean |
| 18 | + default: false |
| 19 | + |
| 20 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 21 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 22 | +# NOTE: There's no option to not cancel pending jobs, but we should be able to avoid race conditions on |
| 23 | +# the published gh-pages branch anyway. The expectation is to have at maximum one running process |
| 24 | +# (after merging to main) and one release process waiting. |
| 25 | +concurrency: |
| 26 | + group: "pages" |
| 27 | + cancel-in-progress: false |
| 28 | + |
| 29 | +jobs: |
| 30 | + build_deploy_pages: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + environment: |
| 33 | + name: github-pages |
| 34 | + |
| 35 | + permissions: |
| 36 | + contents: write |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@v3 |
| 41 | + |
| 42 | + - name: Set up Python 3.12 |
| 43 | + uses: actions/setup-python@v4 |
| 44 | + with: |
| 45 | + python-version: "3.12" |
| 46 | + |
| 47 | + - name: Install dependencies |
| 48 | + run: | |
| 49 | + python -m pip install --upgrade pip |
| 50 | + python -m pip install poetry |
| 51 | + poetry config virtualenvs.create false |
| 52 | + poetry install --no-root --with dev |
| 53 | +
|
| 54 | + - name: Configure Git user |
| 55 | + run: | |
| 56 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 57 | + git config --local user.name "github-actions[bot]" |
| 58 | +
|
| 59 | + - name: Make sure previous versions are available to mike |
| 60 | + run: | |
| 61 | + git fetch origin gh-pages --depth=1 |
| 62 | +
|
| 63 | + - name: Build and deploy static pages |
| 64 | + run: | |
| 65 | + mike deploy ${{ inputs.site-version }} ${{ inputs.version-alias }} --update-aliases --push --branch ${{ inputs.branch }} |
| 66 | +
|
| 67 | + - name: Set default site version |
| 68 | + if: ${{ inputs.site-default }} |
| 69 | + run: | |
| 70 | + mike set-default ${{ inputs.set-version }} --push --branch ${{ inputs.branch }} |
| 71 | +
|
| 72 | + # `mike` is specifically built to be used together with GitHub pages. |
| 73 | + # To upload the website to another service (i.e. AWS S3) uncomment |
| 74 | + # the following step to download the rendered HTML documentation to ./site directory. |
| 75 | + # You'll need to implement the upload steps for your provider. |
| 76 | + |
| 77 | +# - name: Download artifact to ./site |
| 78 | +# run: | |
| 79 | +# rm -rf ./site |
| 80 | +# git archive -o site.tar ${{ inputs.branch }} |
| 81 | +# mkdir -p ./site |
| 82 | +# tar xf site.tar -C ./site |
0 commit comments