karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.3k stars 851 forks source link

Add release-note for auto update docker image PR of dependabot #5170

Open liangyuanpeng opened 3 weeks ago

liangyuanpeng commented 3 weeks ago

What would you like to be added:

now, we use dependabot to auto update the docker base image, but the pr have not the release-note.

we can use a github action to do it and consider the security of github action permission, we may wan't it.

and the second option is running it with a prowjob( presubmit job), and leave the code to hack/release-note-updater/main.go

something like that:

    ghtoken := os.Getenv("GITHUB_TOKEN")
    ts := oauth2.StaticTokenSource(
        &oauth2.Token{AccessToken: ghtoken},
    )
    tc := oauth2.NewClient(context.TODO(), ts)
    ghclient := github.NewClient(tc)

    owner := "liangyuanpeng"
    repo := "karmada"
    prnum := 65
        // ^^^ can read it from prowjob env 

    pr, _, err := ghclient.PullRequests.Get(context.TODO(), owner, repo, prnum)
    if err != nil {
        panic(err)
    }

        releaseNote := "The base image `alpine` has been bumped from 3.20.0 to 3.20.1 "
        // parse pr title to get it ^^^

    newbody := pr.GetBody() + "```release-note\n  .  \n```"
    updatepr := &github.PullRequest{
        Body: &newbody,
    }

    _, _, err = ghclient.PullRequests.Edit(context.TODO(), owner, repo, prnum, updatepr)
    if err != nil {
        panic(err)
    }

Why is this needed:

Auto add a release-note for pr of dependabot.

liangyuanpeng commented 3 weeks ago

cc @RainbowMango

RainbowMango commented 3 weeks ago

Generally, I like the idea, thanks. My concern is it might need some effort to make it becomes steady. Maybe you can have a try and share a demo with us.