![]() Automate updating of dependency files when a new version is released src/package-updater/auth.js, which will handle this flow:Īnd now we are coming to the bonus part. There is an extensive docs on the octocit/rest methods and usage on their GitHub Pages as well. Besides, we are going to use octokit/rest which is an official REST API client for GitHub API. We are using octokip/app package for this part. ![]() After that, we can use this JWT to acquire access tokens for separate installations. To authenticate as app we need to generate a JWT signed by app’s private key which we have saved previously. We need to start with authenticating as an app, as it is required for any further interaction with GitHub API. In this mode GitHub App can actually use all permissions we have granted it during set up. Remember, when you have installed the app into your account? That is it, each of such installation can be accessed separately. ![]() In such way it can get general information about the application itself. There are two ways in which GitHub App can authorize: Implement authorization flow for GitHub App Finally, select “Only on this account” for “Where can this GitHub App be installed?” question and hit Create button.Īfter that we can get to the first step of mastering GitHub App - authorizing as our application. That should be enough for our first iteration and it is always possible to update these settings later. First of all, set “Repository contents” to Read & Write access, as well as for “Pull Requests”. Then, we need to set up permissions for our GitHub App. And then paste your webhook proxy URL (or actual URL of you server) into both “Homepage URL” and “ Webhook URL”. Fill the name field with one you like, for example, “package.json update via Node.js” in my case. ![]() Now you need to create a GitHub App in the “Developers settings” section of your GitHub settings page. If you use Smee.io, for now just click “Start a new channel” and copy the link in “Webhook Proxy URL” field. Smee.io is a service which receives payloads at address available on the web and then sends them to your locally running application. You could either use your own cloud server (such as AWS, Digital Ocean or Heroku) or use a Smee.io. Image from Create GitHub App on the GitHub Dashboardīefore actually going to GitHub we will need an address for the app’s webhook and “landing page”. When done with it we’ll update to fully automated search of the repositories which use our package and proposing them PRs with updates to a newer version. In this tutorial we will start with the “manual” way (which actually isn’t that manual, as it is ran by a separate script). When a new version of the package is released we can then go over them and update in the manner described for fully automated approach. If we do have reasonably small amount of projects dependent on our package what we can do is to have a list of all such repositories. In that branch modify “package.json” file to match a new version of our package and the create a Pull Request to the repository’s default branch. For each of such repositories we then create a branch for the update. On push to master (and possibly successful CI build) iterate over all the repositories which are mentioned in the “used by” section of our package repository’s metadata. There are several options how we can approach this task with GitHub Apps: When we release a new version of the package we wan’t to update the version used across our whole organization. Let’s say we have a repository with a JavaScript package which is used across our other projects. Today we will go through a quite simple flow to better understand nature of GitHub Apps as well as create our own with Node.js. Although it’s not that hard to apply those tutorials to Node.js environment I prefer to have handy information for each tool I use. But they only use Ruby and cover quite a small amount of topics. They do have quite nice tutorials on GitHub regarding these innovations. GitHub’s how-to on the decision making for OAuth vs GitHub Apps.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |