mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-15 23:55:36 +00:00
preview doc action
add docs preview permission update preview action udpate action
This commit is contained in:
66
.github/workflows/docs-preview.yml
vendored
66
.github/workflows/docs-preview.yml
vendored
@@ -10,6 +10,12 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
# This workflow contains jobs "deploy-production"
|
# This workflow contains jobs "deploy-production"
|
||||||
deploy-preview:
|
deploy-preview:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
pull-requests: write
|
||||||
# The environment this job references
|
# The environment this job references
|
||||||
environment:
|
environment:
|
||||||
name: Preview
|
name: Preview
|
||||||
@@ -32,6 +38,7 @@ jobs:
|
|||||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
submodules: recursive # Fetch submodules
|
submodules: recursive # Fetch submodules
|
||||||
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
|
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
# Step 2 Detect changes to Docs Content
|
# Step 2 Detect changes to Docs Content
|
||||||
- name: Detect changes in doc content
|
- name: Detect changes in doc content
|
||||||
@@ -58,36 +65,35 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cd docSite && hugo mod get -u github.com/colinwilson/lotusdocs@6d0568e && hugo -v --minify
|
run: cd docSite && hugo mod get -u github.com/colinwilson/lotusdocs@6d0568e && hugo -v --minify
|
||||||
|
|
||||||
# Step 5 - Push our generated site to Vercel
|
# Step 5 - Push our generated site to Cloudflare
|
||||||
- name: Deploy to Vercel
|
- name: Deploy to Cloudflare Pages
|
||||||
uses: amondnet/vercel-action@v25
|
id: deploy
|
||||||
id: vercel-action
|
uses: cloudflare/wrangler-action@v3
|
||||||
with:
|
with:
|
||||||
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} #Required
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} #Required
|
command: pages deploy ./docSite/public --project-name=fastgpt-doc
|
||||||
github-comment: false
|
packageManager: npm
|
||||||
vercel-args: '--local-config ../vercel.json' # Optional
|
|
||||||
working-directory: docSite/public
|
- name: Create deployment status comment
|
||||||
alias-domains: | #Optional
|
if: always()
|
||||||
fastgpt-staging.vercel.app
|
env:
|
||||||
docsOutput:
|
JOB_STATUS: ${{ job.status }}
|
||||||
permissions:
|
PREVIEW_URL: ${{ steps.deploy.outputs.deployment-url }}
|
||||||
pull-requests: write
|
uses: actions/github-script@v6
|
||||||
needs: [deploy-preview]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.ref }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
|
||||||
- uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
||||||
script: |
|
script: |
|
||||||
github.rest.issues.createComment({
|
const success = process.env.JOB_STATUS === 'success';
|
||||||
issue_number: context.issue.number,
|
const deploymentUrl = `${process.env.PREVIEW_URL}`;
|
||||||
owner: context.repo.owner,
|
const status = success ? '✅ Success' : '❌ Failed';
|
||||||
repo: context.repo.repo,
|
console.log(process.env.JOB_STATUS);
|
||||||
body: '[👀 Visit preview document](${{ needs.deploy-preview.outputs.url }})'
|
|
||||||
})
|
const commentBody = `**Deployment Status: ${status}**
|
||||||
|
${success ? `🔗 Preview URL: ${deploymentUrl}` : ''}`;
|
||||||
|
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
...context.repo,
|
||||||
|
issue_number: context.payload.pull_request.number,
|
||||||
|
body: commentBody
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user