diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 64bbfed4..ca428bc9 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -5,12 +5,25 @@ on: branches: - main paths: ["docs/**/*"] + workflow_dispatch: jobs: deploy: - runs-on: ubuntu-20.04 + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + with: + fetch-depth: 1 - uses: dtolnay/rust-toolchain@stable with: @@ -22,9 +35,25 @@ jobs: - run: mdbook build working-directory: ./docs - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - if: ${{ github.ref == 'refs/heads/main' }} + - name: Archive artifact + shell: sh + working-directory: ./docs/book + run: | + tar \ + --dereference --hard-dereference \ + -cvf "$RUNNER_TEMP/artifact.tar" \ + --exclude=.git \ + --exclude=.github \ + . + + - name: Upload artifact + uses: actions/upload-artifact@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs/book + name: "github-pages" + path: ${{ runner.temp }}/artifact.tar + retention-days: 1 + if-no-files-found: error + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2