diff --git a/azure-pipelines_yml_del b/azure-pipelines_yml_del deleted file mode 100644 index c15f50247d..0000000000 --- a/azure-pipelines_yml_del +++ /dev/null @@ -1,150 +0,0 @@ -name: ng-alain-delon - -trigger: - - master - -pool: - vmImage: 'ubuntu-latest' - -stages: - - stage: env - jobs: - - job: Nodes - steps: - - task: NodeTool@0 - inputs: - versionSource: 'fromFile' - versionFilePath: '.nvmrc' - displayName: 'Install Node.js' - - - stage: build - jobs: - - job: build - steps: - - task: NodeTool@0 - inputs: - versionSource: 'fromFile' - versionFilePath: '.nvmrc' - displayName: 'Install Node.js' - - script: | - node --version - yarn --version - yarn install - displayName: 'Install' - - task: Bash@3 - env: - ACCESS_TOKEN: $(ACCESS_TOKEN) - inputs: - targetType: 'filePath' - filePath: 'scripts/ci/build-artifacts.sh' - displayName: 'Build artifacts' - - script: | - node ./scripts/azure/github-comment.js "[Preview Preparing...](https://dev.azure.com/ng-alain/delon/_build/results?buildId=$(Build.BuildId))" - displayName: 'Comment on github' - env: - ACCESS_REPO: $(ACCESS_REPO) - ACCESS_TOKEN: $(ACCESS_TOKEN) - - script: | - yarn run site:build - displayName: 'Build site' - - script: | - export DEPLOY_DOMAIN=https://preview-${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}-ng-alain-delon.surge.sh - echo "Deploy to $DEPLOY_DOMAIN" - cp ./src/dist/browser/index.html ./src/dist/browser/404.html - npx surge --project ./src/dist/browser --domain $DEPLOY_DOMAIN - displayName: 'Deploy Site' - env: - ACCESS_REPO: $(ACCESS_REPO) - ACCESS_TOKEN: $(ACCESS_TOKEN) - SURGE_LOGIN: $(SURGE_LOGIN) - SURGE_TOKEN: $(SURGE_TOKEN) - - script: | - export DEPLOY_DOMAIN=https://preview-${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}-ng-alain-delon.surge.sh - node ./scripts/azure/github-comment.js "[Preview is ready!]($DEPLOY_DOMAIN)" - displayName: 'Update comment on github' - env: - ACCESS_REPO: $(ACCESS_REPO) - ACCESS_TOKEN: $(ACCESS_TOKEN) - - job: Build_Failed - dependsOn: Build - condition: failed() - steps: - - task: NodeTool@0 - inputs: - versionSource: 'fromFile' - versionFilePath: '.nvmrc' - displayName: 'Install Node.js' - - checkout: self - displayName: 'Checkout' - clean: true - fetchDepth: 1 - - script: yarn install - displayName: 'Install modules' - - script: | - node ./scripts/azure/github-comment.js "[Preview Failed](https://dev.azure.com/ng-alain/delon/_build/results?buildId=$(Build.BuildId))" - displayName: 'Comment on github' - env: - ACCESS_REPO: $(ACCESS_REPO) - ACCESS_TOKEN: $(ACCESS_TOKEN) - dependsOn: env - - - stage: test - jobs: - - job: packages - steps: - - task: NodeTool@0 - inputs: - versionSource: 'fromFile' - versionFilePath: '.nvmrc' - displayName: 'Install Node.js' - - script: yarn install - displayName: 'Install' - - script: | - yarn run test - cat ./coverage/lcov.info | ./node_modules/.bin/codecov - env: - CODECOV_TOKEN: $(CODECOV_TOKEN) - - - task: PublishCodeCoverageResults@1 - displayName: 'publish code coverage results' - condition: succeededOrFailed() - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: $(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml - reportDirectory: $(System.DefaultWorkingDirectory)/coverage - failIfCoverageEmpty: true - - - task: PublishTestResults@2 - displayName: 'publish test results' - condition: succeededOrFailed() - inputs: - searchFolder: $(System.DefaultWorkingDirectory)/junit - failTaskOnFailedTests: true - testRunTitle: DELON - testResultsFormat: JUnit - testResultsFiles: '**/TESTS*.xml' - - job: cli - steps: - - task: NodeTool@0 - inputs: - versionSource: 'fromFile' - versionFilePath: '.nvmrc' - displayName: 'Install Node.js' - - script: yarn install - displayName: 'Install' - - script: yarn run test:cli - dependsOn: env - - - stage: lint - jobs: - - job: packages - steps: - - task: NodeTool@0 - inputs: - versionSource: 'fromFile' - versionFilePath: '.nvmrc' - displayName: 'Install Node.js' - - script: yarn install - displayName: 'Install' - - script: yarn run lint - dependsOn: env diff --git a/scripts/azure/github-comment.js b/scripts/azure/github-comment.js deleted file mode 100644 index d1a4595e2a..0000000000 --- a/scripts/azure/github-comment.js +++ /dev/null @@ -1,61 +0,0 @@ -const REPO = process.env.ACCESS_REPO; -const TOKEN = process.env.ACCESS_TOKEN; -const PR = process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER; -const REPLACE_MARK = ''; - -const argv = process.argv; - -const comment = argv[argv.length - 1]; - -const wrappedComment = ` - ${REPLACE_MARK} - ${comment} -`.trim(); - -async function withGithub(url, json, method) { - const res = await fetch(url, { - method: method || (json ? 'POST' : 'GET'), - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - Authorization: `Basic ${Buffer.from(TOKEN).toString('base64')}`, - }, - body: json ? JSON.stringify(json) : undefined, - }); - - return res.json(); -} - -(async function run() { - if (PR == null) { - console.log('未获取到PR,忽略处理') - return; - } - - const commentUrl = `https://api.github.com/repos/${REPO}/issues/${PR}/comments`; - console.log(`commentUrl`, commentUrl); - const comments = await withGithub(commentUrl); - console.log(`comments data`, comments); - - // Find my comment - const updateComment = comments.find(({ body }) => body.includes(REPLACE_MARK)); - console.log('Origin comment:', updateComment); - - // Update - let res; - if (!updateComment) { - res = await withGithub(commentUrl, { - body: wrappedComment, - }); - } else { - res = await withGithub( - `https://api.github.com/repos/${REPO}/issues/comments/${updateComment.id}`, - { - body: wrappedComment, - }, - 'PATCH', - ); - } - - console.log(res); -})();