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

support GitHub Apps #1766

Merged
merged 1 commit into from
Nov 28, 2020
Merged

support GitHub Apps #1766

merged 1 commit into from
Nov 28, 2020

Conversation

xuwei-k
Copy link
Contributor

@xuwei-k xuwei-k commented Nov 25, 2020

fix #102

How to use

1. create GitHub App

https://github.com/settings/apps/new

GitHub App name set some appropriate name. e.g. scala-steward-app ?

Homepage URL set some appropriate url. e.g. https://github.com/scala-steward-org ?

img1

not require Webhook

webhook

use Metadata Read-only permission only

not require another permissions

permission

select Any account

any account

2. Generate and save Private Key

go to https://github.com/settings/apps/{your application name}

Generate a private key

private-key

3. Install

https://github.com/apps/{your application name}/installations/new

select some organizations and/or repositories

install

4. run

--github-app-id is

app-id

--github-app-key-file is generated private key.

{application name}.{date}.private-key.pem

@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #1766 (80de957) into master (8274524) will decrease coverage by 1.93%.
The diff coverage is 3.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1766      +/-   ##
==========================================
- Coverage   76.52%   74.58%   -1.94%     
==========================================
  Files         118      123       +5     
  Lines        1989     2042      +53     
  Branches       56       58       +2     
==========================================
+ Hits         1522     1523       +1     
- Misses        467      519      +52     
Impacted Files Coverage Δ
.../scala/org/scalasteward/core/application/Cli.scala 96.15% <ø> (ø)
...la/org/scalasteward/core/application/Context.scala 0.00% <ø> (ø)
...org/scalasteward/core/application/StewardAlg.scala 0.00% <0.00%> (ø)
...scalasteward/core/vcs/github/GitHubAppApiAlg.scala 0.00% <0.00%> (ø)
...g/scalasteward/core/vcs/github/GitHubAuthAlg.scala 0.00% <0.00%> (ø)
...scalasteward/core/vcs/github/InstallationOut.scala 0.00% <0.00%> (ø)
...scalasteward/core/vcs/github/RepositoriesOut.scala 0.00% <0.00%> (ø)
...la/org/scalasteward/core/vcs/github/TokenOut.scala 0.00% <0.00%> (ø)
...ala/org/scalasteward/core/application/Config.scala 90.00% <100.00%> (+0.34%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8274524...80de957. Read the comment docs.

@fthomas
Copy link
Member

fthomas commented Nov 26, 2020

Thanks for the PR @xuwei-k, this looks very interesting!

I've one question. The GitHub App is used to get the list of repositories (via installations) as an alternative to the repos file, right? So the usual Scala Steward user (instead of the GH App account) is still used for creating PRs.

@xuwei-k
Copy link
Contributor Author

xuwei-k commented Nov 26, 2020

The GitHub App is used to get the list of repositories (via installations) as an alternative to the repos file, right? So the usual Scala Steward user (instead of the GH App account) is still used for creating PRs.

Yes, that's right.

Copy link
Member

@fthomas fthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, I only have a few minor comments.

}

/** [[https://docs.github.com/en/free-pro-team@latest/developers/apps/authenticating-with-github-apps#authenticating-as-a-github-app]] */
def createJWT(app: GitHubApp, ttl: Duration): String = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be suspended in F[_] since it contains side effects (reading the key file and getting the current time).

I guess the ttl could also be a FiniteDuration since infinite Durations don't make much sense here.

project/Dependencies.scala Show resolved Hide resolved
@@ -44,7 +47,8 @@ final class StewardAlg[F[_]](config: Config)(implicit
selfCheckAlg: SelfCheckAlg[F],
streamCompiler: Stream.Compiler[F, F],
workspaceAlg: WorkspaceAlg[F],
F: BracketThrow[F]
F: BracketThrow[F],
githubAppApiAlg: GitHubAppApiAlg[F]
) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I find it nicer if the F parameter comes last and everything else is sorted alphabetically.

@fthomas fthomas added the enhancement New feature or request label Nov 28, 2020
@fthomas fthomas added this to the 0.9.0 milestone Nov 28, 2020
@fthomas fthomas merged commit 2253604 into scala-steward-org:master Nov 28, 2020
@laughedelic
Copy link

This looks great! @fthomas are you planning to set up an official Scala Steward app?

@xuwei-k xuwei-k deleted the github-app branch November 30, 2020 03:41
@fthomas
Copy link
Member

fthomas commented Nov 30, 2020

Yes, I will and I'll post the details here when it is running.

@fthomas
Copy link
Member

fthomas commented Nov 30, 2020

https://github.com/apps/scala-steward is now up and running. Feel free to try it but please don't publicize it. I'm not sure yet if it will completely replace the current repos.md. I fear that the app could lead to DOS attacks.


/** [[https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-repositories-accessible-to-the-app-installation]]
*
* TODO pagination use `page` query param
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was referenced Mar 15, 2021
@fthomas
Copy link
Member

fthomas commented Sep 20, 2021

FYI: I disabled the https://github.com/apps/scala-steward app again. For all users of that app: if you want to continue receiving updates by Scala Steward, you can add your repo to https://github.com/scala-steward-org/repos/blob/main/repos-github.md.

@nafg
Copy link
Contributor

nafg commented Oct 3, 2022

What was the reason for disabling it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use GitHub to install Scala steward in a repo
4 participants