Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRs opened from a non collaborator fork can't post a comment #255

Open
eygraber opened this issue Oct 5, 2023 · 0 comments
Open

PRs opened from a non collaborator fork can't post a comment #255

eygraber opened this issue Oct 5, 2023 · 0 comments

Comments

@eygraber
Copy link
Contributor

eygraber commented Oct 5, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant