From d7bc4ef233f7aa4d364975962b8d862bf51fcc04 Mon Sep 17 00:00:00 2001 From: Aritra Dey Date: Sat, 22 Nov 2025 21:27:32 +0530 Subject: [PATCH 1/6] ci: consolidate docs deployment workflows and add PR previews Signed-off-by: Aritra Dey --- .github/workflows/build.yml | 16 ---------- .github/workflows/deploy.yml | 21 ------------ .github/workflows/publish-docs.yml | 51 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/publish-docs.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 0eae7326..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: build -on: - pull_request: - branches: [master] -jobs: - build: - runs-on: ubuntu-latest - name: Build Test - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v2.3.1 - - - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. - run: | - npm install - npm run build \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 65e4ed40..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: deploy -on: - push: - branches: [master] -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v2.3.1 - - - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. - run: | - npm install - npm run build - - - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@4.1.4 - with: - branch: gh-pages # The branch the action should deploy to. - folder: build # The folder the action should deploy. diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml new file mode 100644 index 00000000..c2414692 --- /dev/null +++ b/.github/workflows/publish-docs.yml @@ -0,0 +1,51 @@ +name: Publish Docs + +on: + push: + branches: [master] + pull_request: + branches: [master] + types: [opened, synchronize, reopened, closed] + +permissions: + contents: write + pull-requests: write + statuses: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install and Build 🔧 + run: | + npm ci + npm run build + + - name: Deploy Preview deploy-preview 🚀 + if: github.event_name == 'pull_request' + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./docusaurus/ + preview-branch: gh-pages-pr-previews + umbrella-dir: pr-preview + action: auto + + - name: Deploy to GitHub Pages 🚀 + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: build From 332e13750c7e2a5d851533d34d4209a5ec594b75 Mon Sep 17 00:00:00 2001 From: Aritra Dey Date: Sat, 22 Nov 2025 22:09:33 +0530 Subject: [PATCH 2/6] fix: source dir path for deployment Signed-off-by: Aritra Dey --- .github/workflows/publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index c2414692..c7c22234 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -38,7 +38,7 @@ jobs: if: github.event_name == 'pull_request' uses: rossjrw/pr-preview-action@v1 with: - source-dir: ./docusaurus/ + source-dir: ./build/ preview-branch: gh-pages-pr-previews umbrella-dir: pr-preview action: auto From 9b6dd7ac51072e9dc74a38dab9176ea5315e95e7 Mon Sep 17 00:00:00 2001 From: Aritra Dey Date: Tue, 25 Nov 2025 14:52:48 +0530 Subject: [PATCH 3/6] fix: pr from forks deployment issue Signed-off-by: Aritra Dey --- .github/workflows/publish-docs.yml | 84 +++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 25 deletions(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index c7c22234..021f95aa 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -5,47 +5,81 @@ on: branches: [master] pull_request: branches: [master] - types: [opened, synchronize, reopened, closed] permissions: contents: write pull-requests: write - statuses: write - id-token: write - -concurrency: - group: "pages" - cancel-in-progress: true jobs: - build-and-deploy: + build: runs-on: ubuntu-latest + steps: - - name: Checkout 🛎️ + - name: Checkout uses: actions/checkout@v4 - - name: Setup Node.js + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version: 20 + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: site + path: build/ + + deploy-pr-preview: + # Runs ONLY for PRs + if: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest + needs: build - - name: Install and Build 🔧 - run: | - npm ci - npm run build + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: site + path: site - - name: Deploy Preview deploy-preview 🚀 - if: github.event_name == 'pull_request' - uses: rossjrw/pr-preview-action@v1 + - name: Deploy PR Preview + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages-pr-previews + folder: site + target-folder: pr-${{ github.event.pull_request.number }} + + - name: Comment Preview URL + uses: marocchino/sticky-pull-request-comment@v2 + with: + recreate: true + message: | + 🚀 **Preview Ready!** + Your docs preview for this PR is available here: + + **https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}/** + + deploy-production: + # Runs ONLY on push to master + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + runs-on: ubuntu-latest + needs: build + + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 with: - source-dir: ./build/ - preview-branch: gh-pages-pr-previews - umbrella-dir: pr-preview - action: auto + name: site + path: site - - name: Deploy to GitHub Pages 🚀 - if: github.event_name == 'push' && github.ref == 'refs/heads/master' + - name: Deploy to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages - folder: build + folder: site From e44a206e187856cb7feb5c10e86f6aa4bc27e168 Mon Sep 17 00:00:00 2001 From: Aritra Dey Date: Tue, 25 Nov 2025 15:20:00 +0530 Subject: [PATCH 4/6] fix workflow Signed-off-by: Aritra Dey --- .github/workflows/publish-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 021f95aa..afdfb347 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -63,8 +63,8 @@ jobs: 🚀 **Preview Ready!** Your docs preview for this PR is available here: - **https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}/** - + **https://pecanproject.github.io/pr-${{ github.event.pull_request.number }}/** + deploy-production: # Runs ONLY on push to master if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} From a1ad3a4f4b4b884fd6496faecf14262f33e6b129 Mon Sep 17 00:00:00 2001 From: Aritra Dey Date: Tue, 25 Nov 2025 15:23:51 +0530 Subject: [PATCH 5/6] fix repo name Signed-off-by: Aritra Dey --- .github/workflows/publish-docs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index afdfb347..ec4ed3a2 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -54,6 +54,7 @@ jobs: branch: gh-pages-pr-previews folder: site target-folder: pr-${{ github.event.pull_request.number }} + workspace: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }} - name: Comment Preview URL uses: marocchino/sticky-pull-request-comment@v2 @@ -64,7 +65,7 @@ jobs: Your docs preview for this PR is available here: **https://pecanproject.github.io/pr-${{ github.event.pull_request.number }}/** - + deploy-production: # Runs ONLY on push to master if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} From 43786f9a72e51349082ed91300416a9fdf3f868d Mon Sep 17 00:00:00 2001 From: Aritra Dey Date: Tue, 25 Nov 2025 15:28:29 +0530 Subject: [PATCH 6/6] add workflow_dispatch for running pr previews Signed-off-by: Aritra Dey --- .github/workflows/publish-docs.yml | 32 ++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index ec4ed3a2..2794503e 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -5,6 +5,16 @@ on: branches: [master] pull_request: branches: [master] + workflow_dispatch: + inputs: + pr_number: + description: 'PR number to deploy preview for' + required: true + type: number + run_id: + description: 'Run ID of the build workflow (from the PR checks)' + required: true + type: string permissions: contents: write @@ -13,7 +23,6 @@ permissions: jobs: build: runs-on: ubuntu-latest - steps: - name: Checkout uses: actions/checkout@v4 @@ -36,43 +45,46 @@ jobs: path: build/ deploy-pr-preview: - # Runs ONLY for PRs - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest - needs: build - steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download build artifact uses: actions/download-artifact@v4 with: name: site path: site + run-id: ${{ inputs.run_id }} + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Deploy PR Preview uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages-pr-previews folder: site - target-folder: pr-${{ github.event.pull_request.number }} - workspace: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }} + target-folder: pr-${{ inputs.pr_number }} - name: Comment Preview URL uses: marocchino/sticky-pull-request-comment@v2 with: recreate: true + number: ${{ inputs.pr_number }} message: | 🚀 **Preview Ready!** Your docs preview for this PR is available here: - **https://pecanproject.github.io/pr-${{ github.event.pull_request.number }}/** + **https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ inputs.pr_number }}/** deploy-production: - # Runs ONLY on push to master if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} runs-on: ubuntu-latest needs: build - steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download build artifact uses: actions/download-artifact@v4 with: