Closed7

GitHub Actionであそぼ

ピン留めされたアイテム
murnanamurnana

で、今回やりたかったのが
「Re-run this job」でもう一度ジョブを実行した際、前回成功したoutputを取得する
ということなのですが…うまくいかない…

const GITHUB_RUN_ATTEMPT = process.env.GITHUB_RUN_ATTEMPT as string
core.debug(`GITHUB_RUN_ATTEMPT: ${GITHUB_RUN_ATTEMPT}`)
const gitHubRunAttempt = parseInt(GITHUB_RUN_ATTEMPT, 10)
core.debug(`gitHubRunAttempt: ${gitHubRunAttempt}`)

if (gitHubRunAttempt > 1) {
  const context = github.context
  core.debug(`github.context: ${JSON.stringify(github.context, null, 2)}`)

  // Get before run workflow
  const result = await octoKit.rest.actions.listJobsForWorkflowRunAttempt({
    owner: context.repo.owner,
    repo: context.repo.repo,
    run_id: context.runId,
    attempt_number: gitHubRunAttempt - 1
  })

  const job = result.data.jobs.find(value => value.name === context.job)
  if (!job) {
    throw new Error(`job: ${context.job} is not found`)
  }
  core.debug(`job: ${JSON.stringify(job, null, 2)}`) // 前回の実行結果まではとれそう
} else {
  // First random
  core.setOutput('random', Math.ceil(Math.random() * 1000))
}
murnanamurnana

dependabotが作ったリモートブランチは強制削除。
こんな感じ

git push --delete origin dependabot/github_actions/actions/checkout-3 dependabot/github_actions/actions/setup-node-3.2.0 dependabot/github_actions/actions/upload-artifact-3 dependabot/github_actions/github/codeql-action-2 dependabot/npm_and_yarn/actions/core-1.8.2 dependabot/npm_and_yarn/prettier-2.6.2 dependabot/npm_and_yarn/types/node-17.0.35 dependabot/npm_and_yarn/typescript-4.6.4 dependabot/npm_and_yarn/typescript-eslint/parser-5.25.0
このスクラップは1ヶ月前にクローズされました