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

Run Renovate as a Github Action #5493

Merged
merged 6 commits into from
Apr 11, 2024
Merged

Conversation

enesonus
Copy link
Contributor

Description

As #5462 requests, this PR adds a workflow file to self-host renovate on github actions to run make generate before creating a PR.

Our goals were (as @negz stated):

  • Renovate automatically runs make generate before opening a PR
  • Ideally renovate runs about as frequently as it does today
  • Ideally we don't lose useful Renovate functionality (e.g. the "click here to rebase" box on Renovate PRs)

Renovate will automatically run make generate before creating a commit using postUpgradeTasks configuration option.
All files will be committed after running a post-upgrade task.
The postUpgradeTask (make generate) will be executed for the whole branch but it can also be configured to execute for every dependency on the branch.

This workflow file runs Renovate everyday at 8 AM UTC. Since I did not know current frequency I made this up.

  schedule:
    - cron: '0 8 * * *'

Probably we will not lose any useful Renovate functionality since there is no mention of functionality difference between Mend Renovate and Self Hosted Renovate in the documentations, but of course I am not %100 sure.

Currently this PR handles authentication via PAT (Personal Access Token) with repo scope as explained in the renovate docs

token: ${{ secrets.RENOVATE_TOKEN }}

Instead of using a Personal Access Token (PAT) that is tied to a particular user it is also possible to create a GitHub App where permissions can be better tuned. For this we need to perform a bit more steps. I don't think we need this but this is an option.

I have:

Need help with this checklist? See the cheat sheet.

@enesonus enesonus requested a review from a team as a code owner March 19, 2024 01:37
@enesonus enesonus requested a review from turkenh March 19, 2024 01:37
Signed-off-by: Mehmet Enes <menes.onus@gmail.com>
Signed-off-by: Mehmet Enes <menes.onus@gmail.com>
.github/renovate.json5 Outdated Show resolved Hide resolved
Co-authored-by: Philippe Scorsolini <p.scorsolini@gmail.com>
Signed-off-by: Mehmet Enes <94247411+enesonus@users.noreply.github.com>
uses: renovatebot/github-action@v40.1.5
with:
configurationFile: .github/renovate.json5
token: ${{ secrets.RENOVATE_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should work, we should be able to create PRs with that:

Suggested change
token: ${{ secrets.RENOVATE_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}

Copy link
Contributor

Choose a reason for hiding this comment

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

no, that won't have all the required access, I'll see if we manage to create an app on monday

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @phisco any updates on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, got lost, I'll make sure to check this out next week 😅

enesonus and others added 2 commits March 23, 2024 18:45
Co-authored-by: Philippe Scorsolini <p.scorsolini@gmail.com>
Signed-off-by: Mehmet Enes <94247411+enesonus@users.noreply.github.com>
Co-authored-by: Philippe Scorsolini <p.scorsolini@gmail.com>
Signed-off-by: Mehmet Enes <94247411+enesonus@users.noreply.github.com>
@enesonus
Copy link
Contributor Author

enesonus commented Mar 23, 2024

Hey @phisco Is there a way I can also run this github action on my fork for testing purposes? It's my first Open Source contribution about Github Actions so I dont have much experince :)

@phisco
Copy link
Contributor

phisco commented Mar 23, 2024

Sure, @enesonus! Github actions have to be on the main branch of your repo for you to be able to run them, so you'll have to merge your commits on master, add one more commit commenting out the if condition we just introduced to allow running it also on forks, and then you can just manually run it. You can do all your changes on your master branch, once you are satisfied you can just port them back on the PR's branch. Let me know if you have any other doubt!

@phisco
Copy link
Contributor

phisco commented Apr 4, 2024

Hey @EnesOnu, sorry again, busy weeks, I've pinged @jbw976 to setup the app, I think it would be better in the long run to use that. So, would you mind switching this PR to use that instead of the PAT in the meantime? Let me know if you need any help 🙏

@enesonus
Copy link
Contributor Author

enesonus commented Apr 4, 2024

Of course I can @phisco . I will work on it at the weekend

Signed-off-by: Mehmet Enes <menes.onus@gmail.com>
@enesonus
Copy link
Contributor Author

enesonus commented Apr 8, 2024

Hey @phisco Renovate bot can be run as a self-hosted GitHub app now. I tested it on my fork and it seems to be working as expected. If you want to have a look here is a workflow run and a PR the bot created at my fork.

Steps required to get the bot up and running are:

  1. Registering a new GitHub App
  2. Install the app
  3. Generate a private key for the app and store it as a secret named RENOVATE_GITHUB_APP_PRIVATE_KEY
  4. Store the GitHub App ID as a secret named RENOVATE_GITHUB_APP_ID

After these steps it should be good to go.

@phisco
Copy link
Contributor

phisco commented Apr 9, 2024

Awesome @enesonus!
@jbw976 let me know when you have configured the app 🙏

@jbw976
Copy link
Member

jbw976 commented Apr 11, 2024

@enesonus @phisco I believe I have completed the steps here to create the GitHub app for self-hosted Renovate. Please let me know if I've missed anything 🕵️

From https://github.com/organizations/crossplane/settings/installations/49496343, we can see the Crossplane-Renovate GitHub App is installed for all repositories in the crossplane organization, with the permissions as described in the renovate docs:
Screenshot 2024-04-11 at 12 41 57 PM

A private key was created and its value, along with the ID of the GitHub APP, were stored as Actions Secrets at the Organization level in https://github.com/organizations/crossplane/settings/secrets/actions. Note that these secrets are only visible to the main crossplane repo to get started. We can expand that to more repos once we have tested.
Screenshot 2024-04-11 at 12 45 01 PM

Let me know if anything else is needed, thanks guys!! 🙇‍♂️

Copy link
Contributor

@phisco phisco left a comment

Choose a reason for hiding this comment

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

Awesome, thanks @jbw976! And thanks a lot for your contribution, @enesonus, looking forward to the next one! 🎉 🎉

@phisco phisco merged commit e86b2ba into crossplane:master Apr 11, 2024
15 of 16 checks passed
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.

None yet

3 participants