Skip to content

Commit

Permalink
Merge branch 'next' of github.com:kongying-tavern/docs into next
Browse files Browse the repository at this point in the history
  • Loading branch information
jiazengp committed Jul 9, 2023
2 parents 709fd4f + ba4d89d commit 33c2982
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check
name: CHECK

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: 'CodeQL'
name: 'CODEQL'

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deployment
name: DEPLOYMENT

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-commented.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Issue Commented
name: ISSUE_COMMENTED

on:
issue_comment:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-daily.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Issue Daily
name: ISSUE_DAILY

on:
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-labeled.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Issue Labeled
name: ISSUE_LABELED

on:
issues:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Links
name: LINKS

on:
push:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# @See https://pages.github.com/
name: Gtihub Pages

env:
- BASE: 'docs'
name: GITHUB_PAGE

on:
# trigger deployment on every push to main branch
Expand Down
97 changes: 97 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: PREVIEW

on:
workflow_call:
secrets:
SURGE_TOKEN:
required: true
workflow_run:
workflows: ["TEST_BUILD"]
types:
- completed
workflow_dispatch:

jobs:
preview-success:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: download pr artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
run_id: ${{ github.event.workflow_run.id }}
name: pr
- name: save PR id
id: pr
run: echo "::set-output name=id::$(<pr-id.txt)"

- name: download _site artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
run_id: ${{ github.event.workflow_run.id }}
name: _site
- run: |
unzip _site.zip
- name: Upload surge service and generate preview URL
id: deploy
run: |
repository=${{github.repository}}
project_name=${repository#*/}
export DEPLOY_DOMAIN=https://kongying-tavern-preview-pr${{ steps.pr.outputs.id }}-$project_name.surge.sh
npx surge --project .vitepress/dist --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
echo the preview URL is $DEPLOY_DOMAIN
echo "::set-output name=url::$DEPLOY_DOMAIN"
- name: update status comment
uses: actions-cool/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
<a href="${{steps.deploy.outputs.url}}">Kongying Tavern PR Preview</a>
<!-- [工作流地址](${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}) -->
<!-- AUTO_PREVIEW_HOOK -->
number: ${{ steps.pr.outputs.id }}
body-include: "<!-- AUTO_PREVIEW_HOOK -->"

- run: |
rm -rf .vitepress/dist
- name: The job failed
if: ${{ failure() }}
uses: actions-cool/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
[失败](${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}})
<!-- AUTO_PREVIEW_HOOK -->
number: ${{ steps.pr.outputs.id }}
body-include: "<!-- AUTO_PREVIEW_HOOK -->"

preview-failed:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'failure'
steps:
- name: download pr artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
run_id: ${{ github.event.workflow_run.id }}
name: pr
- name: save PR id
id: pr
run: echo "::set-output name=id::$(<pr-id.txt)"
- name: The job failed
uses: actions-cool/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
[失败](${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}})
<!-- AUTO_PREVIEW_HOOK -->
number: ${{ steps.pr.outputs.id }}
body-include: "<!-- AUTO_PREVIEW_HOOK -->"
2 changes: 1 addition & 1 deletion .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PrSpellCheck
name: PRSPELLCHECK
on: [pull_request]

jobs:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: TEST_BUILD

on:
workflow_call:
pull_request:
branches: [next, main]
types: [opened, synchronize, reopened]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
with:
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: '16'

# cache node_modules
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: Install dependencies
uses: pnpm/action-setup@v2
with:
run_install: true

# 构建
- name: Build
run: pnpm vitepress build --base /

- run: |
zip -r _site.zip .vitepress/dist
- name: upload _site artifact
uses: actions/upload-artifact@v2
with:
name: _site
path: _site.zip
retention-days: 5

- name: Save PR number
if: ${{ always() }}
run: echo ${{ github.event.number }} > ./pr-id.txt

- name: Upload PR number
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: pr
path: ./pr-id.txt

0 comments on commit 33c2982

Please sign in to comment.