-
Notifications
You must be signed in to change notification settings - Fork 20
CI: consolidate docs deployment workflows and add PR previews #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
infotroph
merged 21 commits into
PecanProject:master
from
AritraDey-Dev:ci/docs-preview-workflow
Jan 30, 2026
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0ef490f
ci: consolidate docs deployment workflows and add PR previews
AritraDey-Dev 5ad25a0
fix: source dir path for deployment
AritraDey-Dev 24893fc
fix: pr from forks deployment issue
AritraDey-Dev 04a96b2
fix workflow
AritraDey-Dev 2abd645
fix repo name
AritraDey-Dev f5ce795
add workflow_dispatch for running pr previews
AritraDey-Dev 17edc1c
feat: switch to rossjrw/pr-preview-action
AritraDey-Dev 83bc984
fix: preview branch
AritraDey-Dev 3dd453e
fix: base url
AritraDey-Dev 85a24f4
fix redirect url
AritraDey-Dev 7102720
fix
AritraDey-Dev 9095d3c
fix deploy url
AritraDey-Dev 2e19910
remove base url changes
AritraDey-Dev 2276fed
check for fork
AritraDey-Dev 2c30be7
trying another action
AritraDey-Dev 794a9de
ci: update preview workflow
AritraDey-Dev 4713582
remove write for pr
AritraDey-Dev adfcc80
add a two step process
AritraDey-Dev dbc940a
make run_id automatic for pr preview
AritraDey-Dev 77430d0
feat: update pr preview workflow with correct base url and deployment…
AritraDey-Dev 1a43557
trivial change to test and prod deploy trigger
AritraDey-Dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| name: Publish Docs | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr_number: | ||
| description: 'PR number to deploy preview for' | ||
| required: true | ||
| type: number | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| build: | ||
| 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 dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Determine Base URL | ||
| id: base-url | ||
| run: | | ||
| REPO_NAME="${{ github.event.repository.name }}" | ||
| OWNER="${{ github.repository_owner }}" | ||
|
|
||
| # Check if it's an org page (owner.github.io) | ||
| if [[ "${REPO_NAME,,}" == "${OWNER,,}.github.io" ]]; then | ||
| BASE_PATH="/" | ||
| else | ||
| BASE_PATH="/$REPO_NAME/" | ||
| fi | ||
|
|
||
| echo "base_path=$BASE_PATH" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
| env: | ||
| BASE_URL: ${{ steps.base-url.outputs.base_path }} | ||
|
|
||
| - name: Upload build artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: site | ||
| path: build/ | ||
|
|
||
| deploy-pr-preview: | ||
| if: ${{ github.event_name == 'workflow_dispatch' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: refs/pull/${{ inputs.pr_number }}/head | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Determine Base URL | ||
| id: base-url | ||
| run: | | ||
| REPO_NAME="${{ github.event.repository.name }}" | ||
| OWNER="${{ github.repository_owner }}" | ||
| PR_NUM="${{ inputs.pr_number }}" | ||
|
|
||
| # Check if it's an org page (owner.github.io) | ||
| if [[ "${REPO_NAME,,}" == "${OWNER,,}.github.io" ]]; then | ||
| BASE_PATH="/pr-$PR_NUM/" | ||
| FULL_URL="https://$OWNER.github.io/pr-$PR_NUM/" | ||
| else | ||
| BASE_PATH="/$REPO_NAME/pr-$PR_NUM/" | ||
| FULL_URL="https://$OWNER.github.io/$REPO_NAME/pr-$PR_NUM/" | ||
| fi | ||
|
|
||
| echo "base_path=$BASE_PATH" >> $GITHUB_OUTPUT | ||
| echo "full_url=$FULL_URL" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
| env: | ||
| BASE_URL: ${{ steps.base-url.outputs.base_path }} | ||
|
|
||
| - name: Deploy PR Preview | ||
| uses: JamesIves/github-pages-deploy-action@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| branch: gh-pages | ||
| folder: build | ||
| target-folder: pr-${{ inputs.pr_number }} | ||
| clean: true | ||
| git-config-name: github-actions[bot] | ||
| git-config-email: github-actions[bot]@users.noreply.github.com | ||
|
|
||
| - 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: | ||
|
|
||
| **${{ steps.base-url.outputs.full_url }}** | ||
|
|
||
| deploy-production: | ||
| 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: | ||
| name: site | ||
| path: site | ||
|
|
||
| - name: Deploy to GitHub Pages | ||
| uses: JamesIves/github-pages-deploy-action@v4 | ||
| with: | ||
| branch: gh-pages | ||
| folder: site |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.