Skip to content
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

deploy the docs app from a PR to gh-pages #1595

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Deploy docs from master commit
on:
push:
branches:
- master
jobs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci && npm run bootstrap
- name: Build docs-app
run: npm run build:docs
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./packages/__docs__/__build__
branch: gh-pages
clean-exclude: pr-preview
force: false
36 changes: 3 additions & 33 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,13 @@ jobs:
with:
fetch-depth: 0
- uses: actions/setup-node@v3
name: Install Node 20
name: Install Node 22
with:
node-version: '20'
node-version: '22'
cache: 'npm'
- name: Install netlify-cli
run: npm install --save-dev [email protected]
- name: Install dependencies
run: npm ci
- name: Bootstrap project
run: npm run bootstrap
- name: Run test for the patchset
run: USE_REACT_STRICT_MODE=1 npm run test:patchset
# commented out because our danger script needs the same version of yarn on master and on a branch.
# TODO uncomment when this PR is merged
# - name: Calculate bundle size
# run: yarn danger ci
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build docs-app
run: npm run build:docs
- name: Deploy preview docs
# only run this step if the PR is not from a fork since repository
# secrets are not passed to forks and we need the repo secrets for the below steps
if: github.event.pull_request.head.repo.full_name == github.repository
id: deploy_to_netlify
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# set <preview_url> variable to be available for the following steps
run: echo "::set-output name=preview_url::$(npx netlify deploy --dir ./packages/__docs__/__build__ --alias ${{ github.event.pull_request.number }} | grep "Website Draft URL" | awk '{print $4}')"
- name: Add Comment to PR with the preview URL
# only run this step if the previous step has not failed
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#steps-context
if: ${{ steps.deploy_to_netlify.outcome == 'success' }}
uses: mshick/add-pr-comment@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'
message: |
Preview URL: ${{ steps.deploy_to_netlify.outputs.preview_url }}
run: USE_REACT_STRICT_MODE=1 npm run test:patchset # TODO run individual checks and tests instead so when one fails the cause is easier to track down
26 changes: 26 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy preview docs from PR
concurrency: preview-${{ github.ref }}
on:
pull_request:
types:
- opened
- reopened
- synchronize
# `pr-preview-action` assumes by default that the preview should be removed during the closed event,
# which it only sees if you explicitly add it to the workflow.
- closed
jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci && npm run bootstrap
- name: Build docs-app
run: npm run build:docs
if: github.event.action != 'closed'
- uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./packages/__docs__/__build__
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
Loading