-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yuxuanxia
authored and
Saraph1nes
committed
Jul 6, 2024
1 parent
5640919
commit adc310b
Showing
2 changed files
with
91 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,9 @@ | ||
name: PR Reviewer | ||
|
||
on: | ||
workflow_dispatch: | ||
on: workflow_call | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
- name: Install dependencies | ||
uses: borales/[email protected] | ||
with: | ||
cmd: install | ||
- name: Eslint | ||
uses: borales/[email protected] | ||
with: | ||
cmd: lint:ci | ||
- name: Run Build | ||
uses: borales/[email protected] | ||
with: | ||
cmd: build | ||
- name: Archive build dist | ||
if: matrix.node-version == '16.x' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-dist | ||
path: dist | ||
|
||
- name: Archive examples | ||
if: matrix.node-version == '16.x' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-examples | ||
path: examples | ||
|
||
upload: | ||
review: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -104,8 +62,8 @@ jobs: | |
const uploadFile = (filePath, key) => { | ||
return new Promise((resolve, reject) => { | ||
cos.uploadFile({ | ||
Bucket: 'cherry-markdown-dev-1301618266', | ||
Region: 'ap-shanghai', | ||
Bucket: 'cherrymd-1301618266', | ||
Region: 'ap-singapore', | ||
Key: key, | ||
FilePath: filePath, | ||
SliceSize: 1024 * 1024 * 5, /* 触发分块上传的阈值,超过5MB使用分块上传,非必须 */ | ||
|
@@ -147,8 +105,6 @@ jobs: | |
body: ` | ||
### 【预览链接】 | ||
通过下方链接查看效果 | ||
- https://cherry-markdown-dev-1301618266.cos-website.ap-shanghai.myqcloud.com/pr${{ github.event.pull_request.number }}/examples/index.html | ||
- https://cherrymd.com/pr${{ github.event.pull_request.number }}/examples/index.html | ||
` | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: PR Test | ||
|
||
on: | ||
pull_request_target: | ||
branches: [main, dev] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
BASE_SHA: ${{ github.event.pull_request.base.sha }} | ||
HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: '${{ env.HEAD_SHA }}' | ||
|
||
- name: Get changed files and operations | ||
run: | | ||
# 使用 GitHub API 获取变更文件列表及其操作 | ||
DIFF_DOCUMENTS=$(gh api repos/${{ github.repository }}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \ | ||
--jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') | ||
echo "Changed files and operations: ${DIFF_DOCUMENTS}" | ||
# 忽略 .github/workflows 下的文件 | ||
GIT_DIFF_FILES=$(echo "${DIFF_DOCUMENTS}" | grep -vE '^\.github\/workflows\/.*' | xargs) | ||
echo "GIT_DIFF_FILES=${GIT_DIFF_FILES}" >> $GITHUB_ENV | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/checkout@v2 | ||
if: ${{ env.GIT_DIFF_FILES }} | ||
with: | ||
repository: ${{ github.repository }} | ||
ref: '${{ env.BASE_SHA }}' | ||
path: base-repo | ||
|
||
- name: Replace changed files | ||
if: ${{ env.GIT_DIFF_FILES }} | ||
run: | | ||
for file in ${{ env.GIT_DIFF_FILES }}; do | ||
cp "$file" "base-repo/$file" | ||
done | ||
- name: Use Node.js 16.x | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.x | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
uses: borales/[email protected] | ||
with: | ||
cmd: install | ||
|
||
- name: Lint Changed Files | ||
if: ${{ env.GIT_DIFF_FILES }} | ||
run: | | ||
for file in ${{ env.GIT_DIFF_FILES }}; do | ||
yarn eslint "$file" | ||
done | ||
- name: Run Build | ||
uses: borales/[email protected] | ||
with: | ||
cmd: build | ||
|
||
- name: Archive build dist | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-dist | ||
path: dist | ||
|
||
- name: Archive examples | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-examples | ||
path: examples | ||
|
||
review: | ||
needs: build | ||
permissions: write-all | ||
uses: ./.github/workflows/pr-reviewer.yml | ||
secrets: inherit |