From 6c935dd8a2ba55e5db13f1f224247e0f1f9b5551 Mon Sep 17 00:00:00 2001 From: Jack Amadeo Date: Wed, 13 May 2026 15:17:34 -0400 Subject: [PATCH] Switch GH pages deploy to actions/artifact workflow (#9025) --- .../workflows/deploy-docs-and-extensions.yml | 49 +++++++------------ .github/workflows/pr-website-preview.yml | 38 +++----------- .../workflows/rebuild-skills-marketplace.yml | 41 +++++++--------- scripts/clean-gh-pages.sh | 39 --------------- 4 files changed, 41 insertions(+), 126 deletions(-) delete mode 100755 scripts/clean-gh-pages.sh diff --git a/.github/workflows/deploy-docs-and-extensions.yml b/.github/workflows/deploy-docs-and-extensions.yml index 36791b17..60bc9236 100644 --- a/.github/workflows/deploy-docs-and-extensions.yml +++ b/.github/workflows/deploy-docs-and-extensions.yml @@ -7,19 +7,20 @@ on: paths: - 'documentation/**' -# Use same concurrency group as PR preview workflow to prevent race conditions -# when both workflows try to modify gh-pages branch simultaneously. -# cancel-in-progress: false ensures production deploys queue and wait rather than -# being cancelled by PR preview workflows. concurrency: - group: pr-preview + group: pages cancel-in-progress: false jobs: deploy: runs-on: ubuntu-latest permissions: - contents: write + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} steps: - name: Checkout the branch @@ -28,7 +29,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 with: - node-version: 20 + node-version: 20 - name: Cache Node.js modules (documentation) uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2 @@ -53,30 +54,14 @@ jobs: working-directory: ./documentation run: ./scripts/verify-build.sh - - name: Checkout gh-pages branch - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - continue-on-error: true # Branch may not exist on first deploy or in forks - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - with: - ref: gh-pages - path: gh-pages-current + - name: Configure GitHub Pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - - name: Preserve pr-preview directory - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - run: | - # Copy pr-preview from current gh-pages to the new build (if it exists) - if [ -d "gh-pages-current/pr-preview" ]; then - cp -r gh-pages-current/pr-preview documentation/build/pr-preview - echo "Preserved pr-preview directory with $(ls gh-pages-current/pr-preview | wc -l) PR previews" - else - echo "No pr-preview directory to preserve" - fi - - - name: Deploy to /gh-pages - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: documentation/build - keep_files: false # Clean deploy - only keep what's in the build + pr-preview - force_orphan: true # Create a fresh commit without history to prevent bloat + path: documentation/build + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/.github/workflows/pr-website-preview.yml b/.github/workflows/pr-website-preview.yml index 4b1e6e35..61d0548b 100644 --- a/.github/workflows/pr-website-preview.yml +++ b/.github/workflows/pr-website-preview.yml @@ -6,33 +6,29 @@ on: - opened - reopened - synchronize - - closed paths: - 'documentation/**' concurrency: - group: pr-preview - cancel-in-progress: false + group: docs-preview-${{ github.event.pull_request.number }} + cancel-in-progress: true jobs: - deploy: + build: runs-on: ubuntu-latest permissions: - contents: write - pull-requests: write + contents: read steps: - name: Checkout the branch uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Setup Node.js - if: github.event.action != 'closed' uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 with: node-version: 20 - name: Install dependencies and build docs working-directory: ./documentation - if: github.event.action != 'closed' env: INKEEP_API_KEY: ${{ secrets.INKEEP_API_KEY }} INKEEP_INTEGRATION_ID: ${{ secrets.INKEEP_INTEGRATION_ID }} @@ -42,26 +38,6 @@ jobs: npm install npm run build - - name: Deploy preview - uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1.8.1 - if: ${{ github.event.pull_request.head.repo.full_name == 'aaif-goose/goose' }} - with: - source-dir: documentation/build - - cleanup: - runs-on: ubuntu-latest - needs: deploy - if: github.event.action == 'closed' && github.event.pull_request.head.repo.full_name == 'aaif-goose/goose' - permissions: - contents: write - steps: - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - with: - fetch-depth: 0 - - - uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 - - - name: Clean up gh-pages branch - run: | - bash scripts/clean-gh-pages.sh - git push origin $(git rev-parse origin/gh-pages):gh-pages --force + - name: Verify docs map was generated + working-directory: ./documentation + run: ./scripts/verify-build.sh diff --git a/.github/workflows/rebuild-skills-marketplace.yml b/.github/workflows/rebuild-skills-marketplace.yml index 846196c6..53f9a136 100644 --- a/.github/workflows/rebuild-skills-marketplace.yml +++ b/.github/workflows/rebuild-skills-marketplace.yml @@ -17,7 +17,7 @@ on: default: 'Manual trigger' concurrency: - group: pr-preview + group: pages cancel-in-progress: false jobs: @@ -25,7 +25,12 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'aaif-goose/goose' permissions: - contents: write + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} steps: - name: Log trigger info @@ -45,7 +50,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 with: - node-version: 20 + node-version: 20 - name: Cache Node.js modules (documentation) uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2 @@ -69,26 +74,14 @@ jobs: working-directory: ./documentation run: ./scripts/verify-build.sh - - name: Checkout gh-pages branch - continue-on-error: true - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - with: - ref: gh-pages - path: gh-pages-current + - name: Configure GitHub Pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - - name: Preserve pr-preview directory - run: | - if [ -d "gh-pages-current/pr-preview" ]; then - cp -r gh-pages-current/pr-preview documentation/build/pr-preview - echo "Preserved pr-preview directory with $(ls gh-pages-current/pr-preview | wc -l) PR previews" - else - echo "No pr-preview directory to preserve" - fi - - - name: Deploy to /gh-pages - uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: documentation/build - keep_files: false - force_orphan: true + path: documentation/build + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/scripts/clean-gh-pages.sh b/scripts/clean-gh-pages.sh deleted file mode 100755 index b19f76e8..00000000 --- a/scripts/clean-gh-pages.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -set -e # Exit on error - -echo "Starting gh-pages branch cleanup..." - -REMOVE_PATHS_FILE="/tmp/remove-paths.txt" -> "$REMOVE_PATHS_FILE" - -dirs_with_visible_files=$(git ls-tree -r origin/gh-pages:pr-preview --name-only 2>/dev/null | \ - grep -v '/\.' | \ - cut -d/ -f1 | \ - sort -u || true) - -all_dirs=$(git ls-tree -d origin/gh-pages:pr-preview --name-only 2>/dev/null || true) - -if [ -z "$all_dirs" ]; then - echo "No directories found in pr-preview or pr-preview does not exist" - rm "$REMOVE_PATHS_FILE" - exit 0 -fi - -while IFS= read -r dir; do - if [ -n "$dir" ]; then - if ! echo "$dirs_with_visible_files" | grep -q "^${dir}$"; then - dir_path="pr-preview/$dir" - echo "Found directory to remove: $dir_path" - echo "$dir_path" >> "$REMOVE_PATHS_FILE" - fi - fi -done <<< "$all_dirs" - -if [ ! -s "$REMOVE_PATHS_FILE" ]; then - echo "No empty or hidden-file-only directories found. Nothing to clean up." - rm "$REMOVE_PATHS_FILE" - exit 0 -fi - -uvx git-filter-repo@2.47.0 --paths-from-file "$REMOVE_PATHS_FILE" --invert-paths --refs origin/gh-pages