diff --git a/.github/workflows/_docs.yml b/.github/workflows/_docs.yml index b912fb75f..e17d1c1c9 100644 --- a/.github/workflows/_docs.yml +++ b/.github/workflows/_docs.yml @@ -1,6 +1,10 @@ on: workflow_call: +permissions: + pages: write + id-token: write + jobs: build: runs-on: ubuntu-latest @@ -28,27 +32,27 @@ jobs: - name: Remove environment.pickle run: rm build/html/.doctrees/environment.pickle - - name: Upload built docs artifact - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 - with: - name: docs - path: build - - name: Sanitize ref name for docs version run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV - - name: Move to versioned directory - run: mv build/html .github/pages/$DOCS_VERSION + - name: Upload artifact + uses: actions/upload-pages-artifact@v5 + with: + path: .github/pages/ - - name: Write switcher.json - run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json + - name: Zip main docs + if: github.ref_name == 'main' + run: | + mv build/html main + zip -r docs.zip main - - name: Publish Docs to gh-pages - if: github.ref_type == 'tag' || github.ref_name == 'main' - # We pin to the SHA, not the tag, for security reasons. - # https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions - uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 + - name: Upload main docs.zip to main pre-release + if: github.ref_name == 'main' + uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: .github/pages - keep_files: true + tag_name: main-docs + prerelease: true + files: docs.zip + name: "Lastest main branch docs" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93bcfcf42..4d0093b2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,8 @@ jobs: uses: ./.github/workflows/_docs.yml permissions: contents: write + pages: write + id-token: write dist: uses: ./.github/workflows/_dist.yml @@ -61,3 +63,12 @@ jobs: uses: ./.github/workflows/_release.yml permissions: contents: write + + pages: + needs: [docs] #might need needs: [releases] + if: github.ref_type == 'tag' || github.ref_type == 'main' + uses: ./.github/workflows/_pages.yml + permissions: + pages: write + id-token: write + contents: read