diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2d0ad5aa..7adc54cb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,10 +3,26 @@ on: push: tags: - 'publish*' + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: write # write: upload release assets (html archive, checksum, manifest) + actions: read # dawidd6/action-download-artifact reads the cache.yml build artifact + pages: write + id-token: write # required for OIDC-based Pages deployment + +# Allow only one concurrent deployment; don't cancel an in-flight deploy +concurrency: + group: "pages" + cancel-in-progress: false + jobs: publish: if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/volume=80gb/spot=false" + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page-url }} steps: - name: Checkout uses: actions/checkout@v7 @@ -73,38 +89,15 @@ jobs: shell: bash -l {0} run: | jb build lectures --path-output ./ -n -W --keep-going - # Create HTML archive for release assets - - name: Create HTML archive - shell: bash -l {0} - run: | - tar -czf lecture-jax-html-${{ github.ref_name }}.tar.gz -C _build/html . - sha256sum lecture-jax-html-${{ github.ref_name }}.tar.gz > html-checksum.txt - - # Create metadata manifest - cat > html-manifest.json << EOF - { - "tag": "${{ github.ref_name }}", - "commit": "${{ github.sha }}", - "timestamp": "$(date -Iseconds)", - "size_mb": $(du -sm _build/html | cut -f1), - "file_count": $(find _build/html -type f | wc -l) - } - EOF - - name: Upload archives to release - uses: softprops/action-gh-release@v3 - with: - files: | - lecture-jax-html-${{ github.ref_name }}.tar.gz - html-checksum.txt - html-manifest.json - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy website to gh-pages - uses: peaceiris/actions-gh-pages@v4 + - name: Deploy to GitHub Pages + id: deployment + uses: quantecon/actions/publish-gh-pages@v0.6.0 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: _build/html/ + build-dir: _build/html cname: jax.quantecon.org + create-release-assets: 'true' + asset-name: 'lecture-jax-html' + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Prepare lecture-jax.notebooks sync shell: bash -l {0} run: |