Error fetching the result of a previous build in Github Actions using Github Script
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- github-actions, javascript, typescript
調査の方向性
No repository file is named; start with the workflow snippets and the actions/github-script@v6 entry point, then inspect the referenced REST endpoints and the failing run logs. Determine why the run identifier and script syntax fail, and verify that the workflow can retrieve the prior test job conclusion for the current branch or pull request.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
I am trying to fetch the result of a previous build in Github Actions using Github Script. The aim is to only execute the current build job if the previous job succeeded.
To Reproduce
Below is my GitHub action:
- name: Get previous test status
uses: actions/github-script@v6
id: get-previous-test-status
with:
github-token: ${{ secrets.GIT_TOKEN }}
script: |
const ref = $(curl -s -H "Authorization: Bearer ${{ secrets.GIT_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs?event=pull_request&branch=${{ github.head_ref }}&status=completed&per_page=1" | jq -r '.workflow_runs[0].id');
const response = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ref,
filter: 'latest',
per_page: 100
});
const previous_job_1 = response.data.jobs.find(job => job.name === 'test');
return previous_job_1.conclusion;
However, when I run this action, I get the following error:
SyntaxError: Invalid or unexpected token
at new AsyncFunction (<anonymous>)
at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15099:16)
at main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15198:26)
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15175:1
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:152[30](https://github.com/genieai-co/genie-app/actions/runs/4228176248/jobs/7343361774#step:5:31):3
at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15233:12)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:[32](https://github.com/genieai-co/genie-app/actions/runs/4228176248/jobs/7343361774#step:5:33))
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
Error: Unhandled error: SyntaxError: Invalid or unexpected token
Also tried this github action:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get previous test status
uses: actions/github-script@v6
id: get-previous-test-status
with:
github-token: ${{ secrets.GIT_TOKEN }}
script: |
const eventName = context.eventName;
const ref = context.payload.pull_request ? context.payload.pull_request.head.sha : context.payload.before;
const response = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ref,
filter: 'latest',
per_page: 100
});
const previous_job_1 = response.data.jobs.find(job => job.name === 'test');
return previous_job_1.conclusion;
but still facing a different issue, not sure how to get the job execution status of the previous build of current branch or PR
RequestError [HttpError]: Not Found
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:6803:21
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error: Unhandled error: HttpError: Not Found
at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15099:16), <anonymous>:5:18)
at async main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15198:20) {
status: 404,
response: {
url: 'https://api.github.com/repos/test-co/vic-app/actions/runs/8d2ce46a0f7f94933a013b49e39a4083158a4c4c/jobs?filter=latest&per_page=100',
status: 404,
headers: {
'access-control-allow-origin': '*',
'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
connection: 'close',
'content-encoding': 'gzip',
'content-security-policy': "default-src 'none'",
'content-type': 'application/json; charset=utf-8',
date: 'Mon, 20 Feb 2023 17:13:49 GMT',
'referrer-policy': 'origin-when-cross-origin, strict-origin-
- 主要言語
- TypeScript
- スター
- 5k
- フォーク
- 586
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
actions/github-script のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
actions/github-script#728 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
actions/github-script#727 · リアクション 1 件 ·
-
{ オープン
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
actions/github-script#724 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
actions/github-script#723 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
actions/github-script#714 · コメント 1 件 · リアクション 4 件 ·
actions/github-script の issue をすべて見る
似ている issue
-
blocklist removal
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
MetaMask/eth-phishing-detect#296544 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pastelsky/bundlephobia#1122 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100