-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
327bd1d
commit 4379258
Showing
4 changed files
with
61 additions
and
43 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
.github/scripts/dependencies-management/link-worklow-to-pr.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = async ({github, context, branchTargetted}) => { | ||
// The current pull request number to link the workflow run. | ||
const pullRequestNumber = process.env.PULL_REQUEST_NUMBER; | ||
|
||
// Retrieve the workflow runs for the repository. | ||
const runs = await github.request('GET /repos/{owner}/{repo}/actions/runs', { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
headers: { | ||
'X-GitHub-Api-Version': '2022-11-28' | ||
} | ||
}) | ||
|
||
// Retrieve the workflow run for the branch targetted. | ||
const workflow = runs.data.workflow_runs.find(run => run.head_branch == branchTargetted) | ||
|
||
// Handle the error case. | ||
let message = `No tests found for the branch ${branchTargetted}`; | ||
if (workflow) { | ||
message = `Tests ran: [Tests results](${workflow.html_url})`; | ||
} | ||
|
||
// Update the pull request with the link to the workflow run. | ||
github.rest.pulls.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: pullRequestNumber, | ||
body: message, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = async ({github, context, branchTargetted, workflowToTrigger}) => { | ||
await github.rest.actions.createWorkflowDispatch({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
workflow_id: workflowToTrigger, | ||
ref: branchTargetted, | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters