mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-23 23:18:36 +08:00
5c943ca139
Some checks failed
Publish Any Commit / build (push) Waiting to run
🔀 Sync mirror to Gitee / mirror (push) Waiting to run
✅ test / lint (push) Waiting to run
✅ test / test-react-legacy (16, 1/2) (push) Waiting to run
✅ test / test-react-legacy (16, 2/2) (push) Waiting to run
✅ test / test-react-legacy (17, 1/2) (push) Waiting to run
✅ test / test-react-legacy (17, 2/2) (push) Waiting to run
✅ test / test-node (push) Waiting to run
✅ test / test-react-latest (dom, 1/2) (push) Waiting to run
✅ test / test-react-latest (dom, 2/2) (push) Waiting to run
✅ test / test-react-latest-dist (dist, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist, 2/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 2/2) (push) Blocked by required conditions
✅ test / test-coverage (push) Blocked by required conditions
✅ test / build (push) Waiting to run
✅ test / test lib/es module (es, 1/2) (push) Waiting to run
✅ test / test lib/es module (es, 2/2) (push) Waiting to run
✅ test / test lib/es module (lib, 1/2) (push) Waiting to run
✅ test / test lib/es module (lib, 2/2) (push) Waiting to run
👁️ Visual Regression Persist Start / test image (push) Waiting to run
Issue Check Inactive / issue-check-inactive (push) Has been cancelled
Bumps [dawidd6/action-download-artifact](https://github.com/dawidd6/action-download-artifact) from 6 to 7. - [Release notes](https://github.com/dawidd6/action-download-artifact/releases) - [Commits](https://github.com/dawidd6/action-download-artifact/compare/v6...v7) --- updated-dependencies: - dependency-name: dawidd6/action-download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: lijianan <574980606@qq.com>
127 lines
4.8 KiB
YAML
127 lines
4.8 KiB
YAML
# Each PR will build preview site that help to check code is work as expect.
|
|
|
|
name: Preview Deploy
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: [Preview Build]
|
|
types:
|
|
- completed
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
upstream-workflow-summary:
|
|
name: upstream workflow summary
|
|
runs-on: ubuntu-latest
|
|
if: github.event.workflow_run.event == 'pull_request'
|
|
outputs:
|
|
jobs: ${{ steps.prep-summary.outputs.result }}
|
|
build-success: ${{ steps.prep-summary.outputs.build-success }}
|
|
build-failure: ${{ steps.prep-summary.outputs.build-failure }}
|
|
steps:
|
|
- name: summary jobs status
|
|
uses: actions/github-script@v7
|
|
id: prep-summary
|
|
with:
|
|
script: |
|
|
const response = await github.rest.actions.listJobsForWorkflowRun({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: ${{ github.event.workflow_run.id }},
|
|
});
|
|
|
|
// { [name]: [conclusion] }, e.g. { 'build preview': 'success' }
|
|
const jobs = (response.data?.jobs ?? []).reduce((acc, job) => {
|
|
if(job?.status === 'completed' && 'name' in job && 'conclusion' in job) {
|
|
acc[job.name] = job.conclusion;
|
|
}
|
|
return acc;
|
|
}, {});
|
|
|
|
const total = Object.keys(jobs).length;
|
|
if(total === 0) core.setFailed('no jobs found');
|
|
|
|
// the name here must be the same as `jobs.xxx.{name}` in preview-build.yml
|
|
// set output
|
|
core.setOutput('build-success', jobs['build preview'] === 'success');
|
|
core.setOutput('build-failure', jobs['build preview'] === 'failure');
|
|
return jobs;
|
|
|
|
deploy-preview:
|
|
name: deploy preview
|
|
permissions:
|
|
actions: read # for dawidd6/action-download-artifact to query and download artifacts
|
|
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments
|
|
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments
|
|
runs-on: ubuntu-latest
|
|
needs: upstream-workflow-summary
|
|
if: github.event.workflow_run.event == 'pull_request'
|
|
steps:
|
|
# We need get PR id first
|
|
- name: download pr artifact
|
|
uses: dawidd6/action-download-artifact@v7
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
name: pr
|
|
|
|
# Save PR id to output
|
|
- name: save PR id
|
|
id: pr
|
|
run: |
|
|
pr_id=$(<pr-id.txt)
|
|
if ! [[ "$pr_id" =~ ^[0-9]+$ ]]; then
|
|
echo "Error: pr-id.txt does not contain a valid numeric PR id. Please check."
|
|
exit 1
|
|
fi
|
|
echo "id=$pr_id" >> $GITHUB_OUTPUT
|
|
|
|
# Download site artifact
|
|
- name: download site artifact
|
|
if: ${{ fromJSON(needs.upstream-workflow-summary.outputs.build-success) }}
|
|
uses: dawidd6/action-download-artifact@v7
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
name: site
|
|
|
|
- name: upload surge service
|
|
id: deploy
|
|
continue-on-error: true
|
|
env:
|
|
PR_ID: ${{ steps.pr.outputs.id }}
|
|
run: |
|
|
export DEPLOY_DOMAIN=https://preview-${PR_ID}-ant-design.surge.sh
|
|
npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
|
|
|
|
- name: success comment
|
|
uses: actions-cool/maintain-one-comment@v3
|
|
if: ${{ steps.deploy.outcome == 'success' }}
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
body: |
|
|
[<img width="300" alt="Preview is ready" src="https://user-images.githubusercontent.com/5378891/72400743-23dbb200-3785-11ea-9d13-1a2d92743846.png">](https://preview-${{ steps.pr.outputs.id }}-ant-design.surge.sh)
|
|
<!-- AUTO_PREVIEW_HOOK -->
|
|
body-include: <!-- AUTO_PREVIEW_HOOK -->
|
|
number: ${{ steps.pr.outputs.id }}
|
|
|
|
- name: failed comment
|
|
if: ${{ fromJSON(needs.upstream-workflow-summary.outputs.build-failure) || steps.deploy.outcome == 'failure' || failure() }}
|
|
uses: actions-cool/maintain-one-comment@v3
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
body: |
|
|
[<img width="300" alt="Preview failed" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png">](https://preview-${{ steps.pr.outputs.id }}-ant-design.surge.sh)
|
|
<!-- AUTO_PREVIEW_HOOK -->
|
|
body-include: <!-- AUTO_PREVIEW_HOOK -->
|
|
number: ${{ steps.pr.outputs.id }}
|
|
|
|
- name: Check surge deploy result and exit if failed
|
|
run: |
|
|
if [ "${{ steps.deploy.outcome }}" != "success" ]; then
|
|
echo "Surge Deploy failed."
|
|
exit 1
|
|
fi
|