-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Set up docs preview with 'mo-doc' * Simplify formatter CI * Add 'docs' npm script * Update CI * Fix * Run 'dfx cache install' * Update github.io domain * Add 'destination_dir' * Fix * Adjust preview message text * Fix * Update CI * Swap out GH Pages deploy action * Fix * Simplify formatter CI * Use Node 20.x * Fix version conflict in package.json * Misc * Clarify preview text
- Loading branch information
Showing
6 changed files
with
175 additions
and
131 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,83 @@ | ||
name: GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
deploy: | ||
strategy: | ||
matrix: | ||
node: [20] | ||
concurrency: gh-pages-${{ github.ref }} | ||
runs-on: ubuntu-20.04 | ||
env: | ||
PR_PATH: pull/${{github.event.number}} | ||
steps: | ||
- name: Comment on PR | ||
uses: hasura/comment-progress@v2.2.0 | ||
if: github.ref != 'refs/heads/main' | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
repository: ${{ github.repository }} | ||
number: ${{ github.event.number }} | ||
id: deploy-preview | ||
message: "⏳ Loading documentation preview..." | ||
|
||
- name: Set domain | ||
run: echo "DOMAIN=dfinity.github.io" >> $GITHUB_ENV | ||
|
||
- name: Checkout website repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Setup dfx | ||
uses: dfinity/setup-dfx@main | ||
|
||
- run: dfx cache install | ||
|
||
- name: Set production base URL | ||
run: echo "BASE_URL=https://${{ env.DOMAIN }}/${{ github.event.repository.name }}/" >> $GITHUB_ENV | ||
|
||
- name: Build docs if main branch | ||
if: github.ref == 'refs/heads/main' | ||
run: npm run docs | ||
|
||
- name: Deploy if main branch | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
if: github.ref == 'refs/heads/main' | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
folder: ./docs | ||
|
||
- name: Set base URL for preview if PR | ||
if: github.ref != 'refs/heads/main' | ||
run: echo "BASE_URL=https://${{ env.DOMAIN }}/${{ github.event.repository.name }}/${{ env.PR_PATH}}/" >> $GITHUB_ENV | ||
|
||
- name: Build PR preview website | ||
if: github.ref != 'refs/heads/main' | ||
run: npm run docs | ||
|
||
- name: Deploy to PR preview | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
if: github.ref != 'refs/heads/main' | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
folder: ./docs | ||
target-folder: ${{ env.PR_PATH }} | ||
|
||
- name: Update comment | ||
uses: hasura/comment-progress@v2.2.0 | ||
if: github.ref != 'refs/heads/main' | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
repository: ${{ github.repository }} | ||
number: ${{ github.event.number }} | ||
id: deploy-preview | ||
message: "✨ Documentation preview for ${{ github.event.after }}:\n\n> **${{ env.BASE_URL }}**\n\n[Source code](https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/)" |
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,31 @@ | ||
name: Delete preview on PR close | ||
|
||
# only trigger on pull request closed events | ||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
delete_preview: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
PR_PATH: pull/${{github.event.number}} | ||
steps: | ||
- name: Make empty dir | ||
run: mkdir public | ||
|
||
- name: Delete folder | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs | ||
destination_dir: ${{ env.PR_PATH }} | ||
|
||
- name: Comment on PR | ||
uses: hasura/comment-progress@v2.2.0 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
repository: ${{ github.repository }} | ||
number: ${{ github.event.number }} | ||
id: deploy-preview | ||
message: "PR closed. Deleted preview at https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/" |
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,19 @@ | ||
name: Tests | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
format: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-22.04] | ||
node: [20] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- run: npm ci | ||
- run: npm run format:check |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.