mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 18:09:22 +08:00
c4ad37991e
Co-authored-by: Amumu <yoyo837@hotmail.com>
101 lines
3.6 KiB
YAML
101 lines
3.6 KiB
YAML
# Each `push on master` will persist image-snapshots that used as compare target in visual regression.
|
|
|
|
name: 👁️ Visual Regression Persist Finish
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["👁️ Visual Regression Persist Start"]
|
|
types:
|
|
- completed
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
upstream-workflow-summary:
|
|
name: upstream workflow summary
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
jobs: ${{ steps.persist_start_job_status.outputs.result }}
|
|
build-success: ${{ steps.persist_start_job_status.outputs.build-success }}
|
|
build-failure: ${{ steps.persist_start_job_status.outputs.build-failure }}
|
|
steps:
|
|
- name: summary jobs status
|
|
uses: actions/github-script@v6
|
|
id: persist_start_job_status
|
|
with:
|
|
# todo: split it out as github actions
|
|
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. { 'test image': '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['test image'] === 'success');
|
|
core.setOutput('build-failure', jobs['test image'] === 'failure');
|
|
return jobs;
|
|
|
|
persist-image-snapshots:
|
|
name: persist image-snapshots
|
|
permissions:
|
|
actions: read # for dawidd6/action-download-artifact to query and download artifacts
|
|
runs-on: ubuntu-latest
|
|
needs: [upstream-workflow-summary]
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v4
|
|
|
|
# We need get persist key first
|
|
- name: Download Visual Regression Ref
|
|
uses: dawidd6/action-download-artifact@v2
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
name: visual-regression-master-ref
|
|
|
|
# Save visual-regression ref to output
|
|
- name: Extra Visual Regression Ref
|
|
id: visuall-regression
|
|
run: echo "id=$(<visual-regression-ref.txt)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download Visual-Regression Artifact
|
|
if: ${{ fromJSON(needs.upstream-workflow-summary.outputs.build-success) }}
|
|
uses: dawidd6/action-download-artifact@v2
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
name: image-snapshots
|
|
path: ./
|
|
|
|
- name: Persist Image Snapshot to OSS
|
|
if: github.ref_name == 'master'
|
|
id: persist
|
|
continue-on-error: true
|
|
env:
|
|
ALI_OSS_AK_ID: ${{ secrets.ALI_OSS_AK_ID }}
|
|
ALI_OSS_AK_SECRET: ${{ secrets.ALI_OSS_AK_SECRET }}
|
|
ALI_OSS_BUCKET: ${{ secrets.ALI_OSS_BUCKET }}
|
|
run: |
|
|
rm package.json
|
|
npm i ali-oss --no-save
|
|
|
|
echo "🤖 Uploading"
|
|
node scripts/visual-regression-upload.js ./imageSnapshots.tar.gz --ref=${{ github.sha }}
|
|
node scripts/visual-regression-upload.js ./visual-regression-ref.txt --ref=${{ github.ref_name }}
|
|
|
|
echo "✅ Uploaded"
|