-
Notifications
You must be signed in to change notification settings - Fork 18
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
Draft
AritraDey-Dev
wants to merge
19
commits into
PecanProject:master
Choose a base branch
from
AritraDey-Dev:ci/docs-preview-workflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d7bc4ef
ci: consolidate docs deployment workflows and add PR previews
AritraDey-Dev 332e137
fix: source dir path for deployment
AritraDey-Dev 9b6dd7a
fix: pr from forks deployment issue
AritraDey-Dev e44a206
fix workflow
AritraDey-Dev a1ad3a4
fix repo name
AritraDey-Dev 43786f9
add workflow_dispatch for running pr previews
AritraDey-Dev 84d2446
feat: switch to rossjrw/pr-preview-action
AritraDey-Dev 63f33bd
fix: preview branch
AritraDey-Dev 1e812af
fix: base url
AritraDey-Dev 170997c
fix redirect url
AritraDey-Dev 1a31f1a
fix
AritraDey-Dev 12f9eec
fix deploy url
AritraDey-Dev 4bf21cb
remove base url changes
AritraDey-Dev 34b8156
check for fork
AritraDey-Dev a77349b
trying another action
AritraDey-Dev 89fa9a2
ci: update preview workflow
AritraDey-Dev 492ce4e
remove write for pr
AritraDey-Dev 4562db8
add a two step process
AritraDey-Dev e24d4c1
make run_id automatic for pr preview
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,98 @@ | ||
| 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 | ||
| run_id: | ||
| description: 'Run ID of the build workflow (from the PR checks)' | ||
| required: true | ||
| type: string | ||
|
|
||
| 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: Build | ||
| run: npm run build | ||
|
|
||
| - 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 | ||
|
|
||
| - 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-${{ 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://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ inputs.pr_number }}/** | ||
|
|
||
| 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this change help with our current changes ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's required for a PR preview for the Docusaurus config. Actually, I was trying to deploy to gh pages using this workflow for a PR in my fork (just to test) , but in every case, the deployed URL was returning 404.
Then I found this fix in Docusaurus config here which fixes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also For this PR, I was looking for a similar way to comment the PR preview automatically, very similar to what Netlify does. Unfortunately, that is only supported by GitHub Pages and GitHub Actions. So, we need to follow a two-step process for the preview, as @dlebauer mentioned in the 2nd option here. It seems like this is the only way to create a preview website for a PR.