为什么“质量检查”部分未显示“查看部署”按钮

时间:2019-05-21 18:14:03

标签: github github-api

这是它在GitHub上的外观预览 enter image description here

这是我创建部署的方式:

;(async () => {
  const repo = await octokit.repos.get({
    owner: process.env.CIRCLE_PROJECT_USERNAME,
    repo: process.env.CIRCLE_PROJECT_REPONAME
  })

  const targetUrl = buildTargetUrl(
    repo.data.id,
    process.env.CIRCLE_BUILD_NUM,
    process.env.CIRCLE_WORKING_DIRECTORY.replace("~", process.env.HOME)
  )

  try {
    const deployment = await octokit.repos.createDeployment({
      environment: "qa",
      owner: process.env.CIRCLE_PROJECT_USERNAME,
      repo: process.env.CIRCLE_PROJECT_REPONAME,
      ref: process.env.CIRCLE_SHA1,
      required_contexts: [],
      task: "deploy"
    })

    await octokit.repos.createDeploymentStatus({
      deployment_id: deployment.data.id,
      environment: "staging",
      owner: process.env.CIRCLE_PROJECT_USERNAME,
      repo: process.env.CIRCLE_PROJECT_REPONAME,
      target_url: targetUrl,
      log_url: targetUrl,
      description: "Deployment has completed",
      state: "success"
    })
  } catch (err) {
    console.log(err)
    process.exit(1)
  }
})()

登台部署是由Now创建的。质量检查部署是使用我的代码创建的。我想念的是什么?

1 个答案:

答案 0 :(得分:0)

我在environment_url中缺少createDeploymentStatus

await octokit.repos.createDeploymentStatus({
  deployment_id: deployment.data.id,
  environment: "staging",
  environment_url: targetUrl,
  owner: process.env.CIRCLE_PROJECT_USERNAME,
  repo: process.env.CIRCLE_PROJECT_REPONAME,
  target_url: targetUrl,
  log_url: targetUrl,
  state: "success"
})