diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml index 78eb0ec8..41041772 100644 --- a/.github/workflows/linkcheck.yml +++ b/.github/workflows/linkcheck.yml @@ -6,26 +6,36 @@ on: workflow_dispatch: jobs: link-checking: - name: Link Checking + name: QuantEcon AI link checking runs-on: "ubuntu-latest" permissions: - issues: write # required for peter-evans/create-issue-from-file + contents: read # read latest release assets via gh api + issues: write # required for QuantEcon link-checker steps: - # Checkout the live site (html) - - name: Checkout - uses: actions/checkout@v7 + # Download the latest release HTML archive (permanent, not subject to artifact expiry) + - name: Get latest release asset URL + id: release + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + ASSET_URL=$(gh api repos/${{ github.repository }}/releases/latest \ + --jq '[.assets[] | select(.name | endswith(".tar.gz")) | .browser_download_url] | first // ""') + if [ -z "$ASSET_URL" ]; then + echo "::error::No .tar.gz asset found on the latest release" + exit 1 + fi + echo "asset-url=$ASSET_URL" >> "$GITHUB_OUTPUT" + - name: Download and extract release HTML + run: | + set -euo pipefail + mkdir -p _site + curl -fsSL "${{ steps.release.outputs.asset-url }}" | tar -xz -C _site + - name: AI-Powered Link Checker + uses: QuantEcon/action-link-checker@main with: - ref: gh-pages - - name: Link Checker - id: lychee - uses: lycheeverse/lychee-action@v2 - with: - fail: false - args: --accept 200..=299,403,503 --base-url https://intro.quantecon.org *.html - - name: Create Issue From File - if: steps.lychee.outputs.exit_code != 0 - uses: peter-evans/create-issue-from-file@v6 - with: - title: Link Checker Report - content-filepath: ./lychee/out.md - labels: report, automated issue, linkchecker + html-path: '_site' + fail-on-broken: 'false' + silent-codes: '403,503' + ai-suggestions: 'true' + create-issue: 'true' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fc3e5361..59d9f4c3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,12 +1,27 @@ -name: Build & Publish to GH-PAGES +name: Build & Publish to GH Pages on: push: tags: - 'publish*' + +permissions: + contents: write # upload release assets; Netlify commit comment + actions: read # dawidd6 download-artifact reads cache.yml's build-cache + statuses: write # Netlify commit status + pages: write # deploy to GitHub Pages + id-token: write # OIDC token for actions/deploy-pages + +concurrency: + group: "pages" + cancel-in-progress: false + jobs: publish: if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} steps: - name: Checkout uses: actions/checkout@v7 @@ -110,12 +125,17 @@ jobs: env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - - name: Deploy website to gh-pages - uses: peaceiris/actions-gh-pages@v4 + - name: Add CNAME for custom domain + run: echo "intro.quantecon.org" > _build/html/CNAME + - name: Setup Pages + uses: actions/configure-pages@v6 + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v5 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: _build/html/ - cname: intro.quantecon.org + path: _build/html/ + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v5 - name: Upload "_build" folder (cache) uses: actions/upload-artifact@v7 with: