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
This commit is contained in:
Marcus Andersson 2022-12-15 09:56:23 +01:00 committed by GitHub
parent f73cdc5e80
commit d0a68b266c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -108,7 +108,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: ['buildPR', 'buildBase'] needs: ['buildPR', 'buildBase']
env: env:
GITHUB_STEP_NUMBER: 7 GITHUB_STEP_NUMBER: 8
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -134,8 +134,9 @@ jobs:
uses: actions/github-script@v6 uses: actions/github-script@v6
with: with:
script: | script: |
const name = 'Detect breaking changes';
const script = require('./.github/workflows/scripts/pr-get-job-link.js') 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 - name: Detect breaking changes
id: breaking-changes id: breaking-changes

View File

@ -1,9 +1,9 @@
module.exports = async ({ github, context, core }) => { module.exports = async ({ name, github, context, core }) => {
const { owner, repo } = context.repo; const { owner, repo } = context.repo;
const url = `https://api.github.com/repos/${owner}/${repo}/actions/runs/${context.runId}/jobs` const url = `https://api.github.com/repos/${owner}/${repo}/actions/runs/${context.runId}/jobs`
const result = await github.request(url) const result = await github.request(url);
const link = `https://github.com/grafana/grafana/runs/${result.data.jobs[0].id}?check_suite_focus=true`; const job = result.jobs.find(j => j.name === name);
core.setOutput('link', link); core.setOutput('link', `${job.html_url}?check_suite_focus=true`);
} }