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 listing repositories via a Github App #222

Merged
merged 11 commits into from
Mar 13, 2021

Conversation

laughedelic
Copy link
Contributor

Hi! I want to expose the functionality introduced in scala-steward-org/scala-steward#1766 by @xuwei-k (hat tip!). The idea is that one can create a Github App and install it in the repositories they want to update from this action.

Notice, this PR is only for using the app to list installations. It's also possible to use a GH app to authenticate, but that's another story and I will have separate PR for it.

This is a WIP, I'll think how to test it and add more details here.

Verified

This commit was signed with the committer’s verified signature.
RaisinTen Darshan Sen

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
@laughedelic laughedelic changed the title add github-app-{id,key} inputs and pass them to Scala Steward Support listing repositories via a Github App Mar 10, 2021
@alejandrohdezma
Copy link
Member

Wow! This is huge! Thank you very much @laughedelic! I will also try to test it in my own repositories. One question though, should we be adding the --repos-file argument to Scala Steward if we are handing the "app" ones?

@laughedelic
Copy link
Contributor Author

One question though, should we be adding the --repos-file argument to Scala Steward if we are handing the "app" ones?

Yes, I thought about it too, but it's a required argument for the Scala Steward CLI, so I'm not sure how to deal with it.
I saw in the original PR that tests have both repos-file and the Github app args set, but I don't know what is the behavior in that case.

@fthomas
Copy link
Member

fthomas commented Mar 10, 2021

I saw in the original PR that tests have both repos-file and the Github app args set, but I don't know what is the behavior in that case.

The list of repos from the GitHub App and the repos file are combined.

@laughedelic
Copy link
Contributor Author

Great! Thanks for the clarification. So we can either have both or just create an empty file if only the app args are passed to the action.

@alejandrohdezma
Copy link
Member

Great! Thanks for the clarification. So we can either have both or just create an empty file if only the app args are passed to the action.

I like the idea of creating an empty file :)

@laughedelic
Copy link
Contributor Author

laughedelic commented Mar 11, 2021

It works! 🚀 Here's how I tested it.

I've set up a personal app and installed it in two test repositories: one public and one private.

Screenshot of the installation Screenshot of the installation

Notice that the required permissions are minimal (as documented), just enough to list repositories

Then I've set up this public repo to test the action: https://github.com/laughedelic/scala-steward-runner with the reference to this branch of my fork:

        uses: laughedelic/scala-steward-action@gh-app-args
        with:
          # used to list repositories:
          github-app-id: 104507
          github-app-key: ${{ secrets.SCALA_STEWARD_APP_PRIVATE_KEY }}
          # used to author pull requests:
          github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

Here

  • SCALA_STEWARD_APP_PRIVATE_KEY is the private key generated on the app creation
  • PERSONAL_ACCESS_TOKEN is just a PAT with repo access (so PRs will be created on my behalf)

In the first successful run logs you can see that it created two PRs:


P.S. I had to commit the built js files to test it. I will clean it up tomorrow and open for code review.

@laughedelic laughedelic marked this pull request as ready for review March 11, 2021 19:40
@laughedelic
Copy link
Contributor Author

@alejandrohdezma I think this is ready. Please, let me know if the docs are not clear enough or anything needs to be refactored.

@alejandrohdezma
Copy link
Member

Sorry for the delay, busy week.

This is great! Thank you very much for this @laughedelic, I'm definitely changing my own projects to using this approach.

@alejandrohdezma alejandrohdezma merged commit 266f831 into scala-steward-org:master Mar 13, 2021
@alejandrohdezma
Copy link
Member

Versions v2.13.0 and v2 have been published containing this change

@laughedelic
Copy link
Contributor Author

Awesome! Thanks 😊

This was referenced Mar 15, 2021
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

Successfully merging this pull request may close these issues.

3 participants