From d0a68b266c5e9196768df5031d7dbce32a33a438 Mon Sep 17 00:00:00 2001 From: Marcus Andersson Date: Thu, 15 Dec 2022 09:56:23 +0100 Subject: [PATCH] Bugfix: Attach correct link to "levitate detect breaking changes"-message included in PR (#60220) * Fixed so we link to the proper job and step. * Fixed according to feedback. * Added check_suite to the job link --- .github/workflows/detect-breaking-changes-build.yml | 5 +++-- .github/workflows/scripts/pr-get-job-link.js | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/detect-breaking-changes-build.yml b/.github/workflows/detect-breaking-changes-build.yml index e9beb73f709..e7a5ebfbb1b 100644 --- a/.github/workflows/detect-breaking-changes-build.yml +++ b/.github/workflows/detect-breaking-changes-build.yml @@ -108,7 +108,7 @@ jobs: runs-on: ubuntu-latest needs: ['buildPR', 'buildBase'] env: - GITHUB_STEP_NUMBER: 7 + GITHUB_STEP_NUMBER: 8 steps: - uses: actions/checkout@v3 @@ -134,8 +134,9 @@ jobs: uses: actions/github-script@v6 with: script: | + const name = 'Detect breaking changes'; const script = require('./.github/workflows/scripts/pr-get-job-link.js') - await script({github, context, core}) + await script({name, github, context, core}) - name: Detect breaking changes id: breaking-changes diff --git a/.github/workflows/scripts/pr-get-job-link.js b/.github/workflows/scripts/pr-get-job-link.js index a4e6bc2f645..ef9bf28d8c9 100644 --- a/.github/workflows/scripts/pr-get-job-link.js +++ b/.github/workflows/scripts/pr-get-job-link.js @@ -1,9 +1,9 @@ -module.exports = async ({ github, context, core }) => { +module.exports = async ({ name, github, context, core }) => { const { owner, repo } = context.repo; const url = `https://api.github.com/repos/${owner}/${repo}/actions/runs/${context.runId}/jobs` - const result = await github.request(url) - const link = `https://github.com/grafana/grafana/runs/${result.data.jobs[0].id}?check_suite_focus=true`; - - core.setOutput('link', link); -} \ No newline at end of file + const result = await github.request(url); + const job = result.jobs.find(j => j.name === name); + + core.setOutput('link', `${job.html_url}?check_suite_focus=true`); +}