Feature: Preview URL for each PR and add pre-release.jan.ai as staging of Jan Docs (#669)

* CloudFlare Pages add Preview URL to PR

---------

Co-authored-by: Hien To <tominhhien97@gmail.com>
This commit is contained in:
hiento09 2023-11-21 10:26:26 +07:00 committed by GitHub
parent 147c32de92
commit 0dd70824e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 4 deletions

View File

@ -6,6 +6,7 @@ on:
- main
paths:
- 'docs/**'
tags: ["v[0-9]+.[0-9]+.[0-9]+-docs"]
pull_request:
branches:
- main
@ -18,7 +19,14 @@ on:
jobs:
deploy:
name: Deploy to GitHub Pages
env:
CLOUDFLARE_ACCOUNT_ID: 9707100ef42a1a25bd70e3ee2137bd0e
CLOUDFLARE_PROJECT_NAME: jan
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
@ -50,15 +58,33 @@ jobs:
- name: Build website
run: sed -i '/process.env.DEBUG = namespaces;/c\// process.env.DEBUG = namespaces;' ./node_modules/debug/src/node.js && yarn build
working-directory: docs
- name: Publish to Cloudflare Pages PR Preview and Staging
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main')
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ env.CLOUDFLARE_PROJECT_NAME }}
directory: ./docs/build
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
id: deployCloudflarePages
- uses: mshick/add-pr-comment@v2
if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main'
with:
message: |
Preview URL: ${{ steps.deployCloudflarePages.outputs.url }}
- name: Add Custome Domain file
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: echo "${{ vars.DOCUSAURUS_DOMAIN }}" > ./docs/build/CNAME
# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -2,7 +2,7 @@ name: Jan Build Electron App
on:
push:
tags: ["v*.*.*"]
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
jobs:
build-macos: