-
Notifications
You must be signed in to change notification settings - Fork 917
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish GitHub Pages previews on every PR
- Loading branch information
1 parent
34d8036
commit 919661b
Showing
5 changed files
with
153 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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,30 @@ | ||
name: Compile GitHub Pages | ||
description: Compiles documentation, code examples, and everything else for deployment on the GitHub Pages site | ||
|
||
inputs: | ||
repository: | ||
default: 'solana-web3.js' | ||
type: string | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Compile | ||
shell: bash | ||
run: pnpm turbo run compile:typedefs compile:ghpages --concurrency=${TURBO_CONCURRENCY:-1} | ||
env: | ||
REACT_EXAMPLE_APP_BASE_PATH: /${{ inputs.repository }}/example/ | ||
|
||
- name: Assemble Deploy Directory | ||
shell: bash | ||
run: | | ||
mkdir -p .ghpages-deploy | ||
mv ./examples/react-app/dist/ .ghpages-deploy/example/ | ||
mv ./docs/* .ghpages-deploy/ | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
include-hidden-files: true | ||
name: ghpages-deploy-artifacts | ||
path: .ghpages-deploy | ||
retention-days: 1 |
This file contains 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,22 @@ | ||
name: Compile v1 Docs | ||
description: Compiles the HTML documentation for the v1.x line of `@solana/web3.js` | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Compile docs | ||
shell: bash | ||
run: pnpm compile:docs | ||
|
||
- name: Assemble Deploy Directory | ||
shell: bash | ||
run: | | ||
mkdir -p .ghpages-deploy/v1.x | ||
mv ./doc/* .ghpages-deploy/v1.x | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
include-hidden-files: true | ||
name: ghpages-deploy-artifacts-v1-docs | ||
path: .ghpages-deploy | ||
retention-days: 1 |
This file contains 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,27 @@ | ||
name: Publish GitHub Pages | ||
description: Downloads compiled code from the artifact cache and deploys it to GitHub Pages | ||
|
||
inputs: | ||
pr-number: | ||
required: false | ||
type: number | ||
repository: | ||
default: 'solana-web3.js' | ||
type: string | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
path: .ghpages-deploy | ||
pattern: ghpages-deploy-artifacts* | ||
merge-multiple: true | ||
|
||
- name: Deploy to Github Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
destination_dir: ${{ inputs.pr-number }}/ | ||
external_repository: solana-labs/${{ inputs.repository }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: .ghpages-deploy |
This file contains 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,67 @@ | ||
name: Preview GitHub Pages | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
- maintenance/* | ||
|
||
env: | ||
# Among other things, opts out of Turborepo telemetry | ||
# See https://consoledonottrack.com/ | ||
DO_NOT_TRACK: '1' | ||
# Some tasks slow down considerably on GitHub Actions runners when concurrency is high | ||
TURBO_CONCURRENCY: 1 | ||
# Enables Turborepo Remote Caching. | ||
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }} | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Dependencies | ||
uses: ./.github/workflows/actions/install-dependencies | ||
|
||
- name: Compile (v1 Docs) | ||
uses: ./.github/workflows/actions/compile-v1-docs | ||
|
||
- name: Compile (rest) | ||
uses: ./.github/workflows/actions/compile-github-pages | ||
with: | ||
pr-number: github.event.pull_request.number | ||
repository: solana-web3.js-pr-preview | ||
|
||
- name: Publish | ||
uses: ./.github/workflows/actions/publish-gh-pages | ||
with: | ||
pr-number: github.event.pull_request.number | ||
repository: solana-web3.js-pr-preview | ||
|
||
- name: Find Existing Preview Link Comment | ||
uses: peter-evans/find-comment@v3 | ||
id: find-comment | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: <!-- GH_PAGES_PREVIEW_BOT_COMMENT --> | ||
|
||
- name: Create Preview Link Comment | ||
uses: actions/github-script@v7 | ||
if: steps.find-comment.outputs.comment-id == '' | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: github.event.pull_request.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: | | ||
<!-- GH_PAGES_PREVIEW_BOT_COMMENT --> | ||
A preview of the GitHub Pages site based on this PR is now available here: | ||
https://solana-labs.github.io/solana-web3.js-pr-preview/${{ github.event.pull_request.number }}/ | ||
}) |
This file contains 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