Skip to content

test: refactor tests for Tag component #72

test: refactor tests for Tag component

test: refactor tests for Tag component #72

Workflow file for this run

name: PR Preview
on:
pull_request:
permissions:
contents: read # Read repository content for checkout 读取仓库内容用于检出代码
pull-requests: write # Write PR comments and status 写入PR评论和状态
issues: write # Create and update issue comments 创建和更新issue评论
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Set ARCO_SITE_DOMAIN
run: echo "ARCO_SITE_DOMAIN=preview-${{ github.event.number }}-arco-design-mobile.surge.sh" >> $GITHUB_ENV
- name: Build sites concurrently
run: |
npm run site:home &
npm run site:pc &
npm run site:mobile &
wait
env:
ARCO_SITE_DOMAIN: ${{ env.ARCO_SITE_DOMAIN }}
- name: Merge output directories
run: |
# Merge files 合并文件
cp -R output_resource/* output/page/
# Create target directories 创建目标目录
mkdir -p merged_output/mobile/react/arco-design/pc
mkdir -p merged_output/mobile/react/arco-design/mobile
# Move directory contents 移动目录内容
mv output/page/home/* merged_output/mobile/react/
mv output/page/pc/* merged_output/mobile/react/arco-design/pc/
mv output/page/mobile/* merged_output/mobile/react/arco-design/mobile/
# Create redirect HTML file 创建重定向 HTML 文件
echo '<html><head><meta http-equiv="refresh" content="0; url=/mobile/react/arco-design/pc/" /></head><body></body></html>' > merged_output/index.html
- name: Install Surge
run: npm install --global surge
- name: Deploy to Surge
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
ARCO_SITE_DOMAIN: ${{ env.ARCO_SITE_DOMAIN }}
run: |
surge ./merged_output ${{ env.ARCO_SITE_DOMAIN }} --token $SURGE_TOKEN
- name: Create/Update PR Comment
uses: actions/github-script@v6
env:
ARCO_SITE_DOMAIN: ${{ env.ARCO_SITE_DOMAIN }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const previewUrl = `https://${process.env.ARCO_SITE_DOMAIN}`;
const commentBody = `✨ **PR Preview Link**: [${previewUrl}](${previewUrl})`;
// Retrieve existing comments 获取已有的评论
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
// Find if there's a comment created by us before 查找是否有我们之前创建的评论
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' &&
comment.body.includes('PR Preview Link');
});
if (botComment) {
// Update existing comment 更新已有评论
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
// Create new comment 创建新评论
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}