Skip to content

Commit

Permalink
chore: setup preview action
Browse files Browse the repository at this point in the history
  • Loading branch information
chengcyber committed Jun 1, 2024
1 parent 5996f95 commit 0012fc8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
57 changes: 57 additions & 0 deletions .github/workflows/website-preview-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Website preview deployment
on:
pull_request:
branches:
- main
paths:
- .github/workflows/website-preview-deploy.yaml
- apps/website/**
permissions:
contents: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
preview-deploy:
name: Preview deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
env:
GITHUB_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }}
run: |
git config --local user.name tiktokbot
git config --local user.email [email protected]
git config --global credential.helper '!f() { echo "protocol=https\nhost=github.com" ; echo "username=oauth_token" ; echo "password=${GITHUB_TOKEN}" ; }; f'
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Set environment variable
run: echo "BASE_URL=/sparo/_preview/pr-${{ github.event.number }}/" >> $GITHUB_ENV
- name: Rush Install(Website)
run: node common/scripts/install-run-rush.js install --to website
- name: Rush build(Website)
env:
BASE_URL: ${{ env.BASE_URL }}
run: node common/scripts/install-run-rush.js build --verbose --production --to website
- name: Deploy to GitHub Pages preview
uses: peaceiris/actions-gh-pages@v4
if: github.event_name == 'pull_request'
with:
github_token: ${{ secrets.BOT_ACCESS_TOKEN }}
publish_dir: ./apps/website/build
destination_dir: _preview/pr-${{ github.event.number }}
- name: Comment on the pull request with preview URL
if: github.event_name == 'pull_request'
uses: hasura/comment-progress@v2
with:
github-token: ${{ secrets.BOT_ACCESS_TOKEN }}
repository: 'tiktok/sparo'
number: ${{ github.event.number }}
id: deploy-preview
message: 'Website Preview: https://tiktok.github.io/sparo/_preview/pr-${{ github.event.number }}/'
recreate: true
2 changes: 1 addition & 1 deletion apps/website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config = {
url: 'https://tiktok.github.io',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/sparo/',
baseUrl: process.env.BASE_URL || '/sparo/',

// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
Expand Down

0 comments on commit 0012fc8

Please sign in to comment.