PRs opened from a non collaborator fork can't post a comment #255
Open
Description
If a non collaborator makes a PR and doesn't add a label, the job fails.
Dangerfile
import systems.danger.kotlin.*
import java.util.Locale
danger(args) {
with(github) {
val labelNames = issue.labels.map { it.name }.toSet()
/*
# --------------------------------------------------------------------------------------------------------------------
# Check if labels were added to the pull request
#--------------------------------------------------------------------------------------------------------------------
*/
val labelsToFilter = setOf("hold", "skip release notes")
val acceptableLabels = labelNames.filter { it !in labelsToFilter }
if(acceptableLabels.isEmpty() && pullRequest.head.ref != "bots/bump-version") {
fail("PR needs labels (hold and skip release notes don't count)")
}
/*
# --------------------------------------------------------------------------------------------------------------------
# Don't merge if there is a WIP or Hold label applied
# --------------------------------------------------------------------------------------------------------------------
*/
if("Hold" in labelNames) fail("This PR cannot be merged with a hold label applied")
/*
# --------------------------------------------------------------------------------------------------------------------
# Check if merge commits were added to the pull request
# --------------------------------------------------------------------------------------------------------------------
*/
val mergeCommitRegex = Regex("^Merge branch '${pullRequest.base.ref}'.*")
if(git.commits.any { it.message.matches(mergeCommitRegex) }) {
fail("Please rebase to get rid of the merge commits in this PR")
}
}
/*
# --------------------------------------------------------------------------------------------------------------------
# Make sure that no crash files or dumps are in the commit
# --------------------------------------------------------------------------------------------------------------------
*/
val touchedFiles = git.createdFiles + git.modifiedFiles
if(touchedFiles.any { it.startsWith("hs_err_pid") || it.startsWith("java_pid") }) {
fail("Please remove any error logs (hs_err_pid*.log) or heap dumps (java_pid*.hprof)")
}
}
Run docker://ghcr.io/danger/danger-kotlin:1.2.0
/usr/bin/docker run --name ghcriodangerdangerkotlin120_7fdd84 --label 94351b --workdir /github/workspace --rm <many env vars> -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/JsonPathKt/JsonPathKt":"/github/workspace" ghcr.io/danger/danger-kotlin:1.2.0 --failOnErrors --no-publish-check
Executing $(which danger) ci --process danger-kotlin --passURLForDSL --failOnErrors --no-publish-check - pid 1
Executing kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /tmp/danger-dsl.json danger_out.json - pid 27
Failing the build, there is 1 fail.
Request failed [403]: https://api.github.com/user
Response: {
"message": "Resource not accessible by integration",
"documentation_url": "https://docs.github.com/rest/users/users#get-the-authenticated-user"
}
Request failed [403]: https://api.github.com/user
Response: {
"message": "Resource not accessible by integration",
"documentation_url": "https://docs.github.com/rest/users/users#get-the-authenticated-user"
}
Request failed [403]: https://api.github.com/repos/eygraber/JsonPathKt/issues/15/comments
Response: {
"message": "Resource not accessible by integration",
"documentation_url": "https://docs.github.com/rest/issues/comments#create-an-issue-comment"
}
Feedback: undefined
Metadata
Assignees
Labels
No labels