Skip to content

Commit

Permalink
feat: test
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyair committed Mar 20, 2024
1 parent d1da5f7 commit 20f78cb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: image-preview

on: [push, pull_request]

jobs:
image-preview-2:
name: image-preview-3
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: image-preview-4
id: report
env:
ALI_OSS_AK_ID: ${{ secrets.ALI_OSS_AK_ID }}
ALI_OSS_AK_SECRET: ${{ secrets.ALI_OSS_AK_SECRET }}
run: |
npm i ali-oss --no-save
echo "✅ Install `ali-oss` Finished"
echo "🤖 Uploading"
node scripts/visual-regression/upload-demo.js
echo "✅ Uploaded"
Binary file added demo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions scripts/visual-regression/upload-demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const OSS = require('ali-oss');

async function uploadFile() {
const client = new OSS({
endpoint: 'oss-cn-shanghai.aliyuncs.com',
accessKeyId: process.env.ALI_OSS_AK_ID,
accessKeySecret: process.env.ALI_OSS_AK_SECRET,
bucket: 'antd-visual-diff',
});

const headers = {
'x-oss-object-acl': 'public-read',
'x-oss-forbid-overwrite': 'false',
'Content-Disposition': 'inline',
'Content-Type': 'image/png',
};
// https://antd-visual-diff.oss-cn-shanghai.aliyuncs.com/pr-47859/visualRegressionReport/images/current/menu-sider-current.compact.png
try {
const r1 = await client.put(`demo/image`, 'demo.png', {
headers,
timeout: 60000 * 2,
});
console.log('r1', r1);

Check warning on line 23 in scripts/visual-regression/upload-demo.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 23 in scripts/visual-regression/upload-demo.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
} catch (err) {
console.log('err', err);

Check warning on line 25 in scripts/visual-regression/upload-demo.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 25 in scripts/visual-regression/upload-demo.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
throw err;
}
}

uploadFile();

0 comments on commit 20f78cb

Please sign in to comment.