Where can we find GitHub Apps Installation ID? - github

I'm setting up a GitHub App for ArgoCD authentication. The GitHub App setup is completed. But in ArgoCD it asks for GitHub App ID and GitHub App Installation ID. I could find the App ID from the GitHub App section itself. But I couldn't find the GitHub App Installation ID.
Is there a way to directly find GitHub App Installation ID from the GitHub website settings section? Or do we need to use GitHub API or something?

The
InstallationID
is the same ID that you can find in the GitHub endpoint:
https://github.com/settings/installations/<ID>

I'm making this answer a little more explanatory.
For GitHub Apps created under Organizations:
Go to the Organization settings
Click on 'GitHub Apps' under 'Third-party Access'
If there are multiple GitHub apps, choose your App and click on 'Configure'
Once your GitHub App is selected check the URL for obtaining 'GitHub App Installation ID'
The URL looks like this:
https://github.com/organizations/<Organization-name>/settings/installations/<ID>
Pick the <ID> part and that's your GitHub App Installation ID.
For GitHub Apps created under Repository, you can find this under repository settings.

Related

How to create user repository via GitHub App API?

A user installed my github app for his personal account (not organization). My github app has read & write administration permissions.
When I perform the request (I use go-github sdk) I get the following error:
POST https://api.github.com/user/repos: 403 Resource not accessible by integration []
There are two different endpoints for creating repositories in organization and for user. Endpoint for creating user repos is the POST method /user/repos. When I look github official documentation on github app permissions it doesn't actually list POST method for user/repos. So it's not clear how to create user repos via github app, if possible at all.
I got a response from github support. This behaviour is expected. To create new repos under a user you have to use user-to-server token (oauth2 token). It can be acquired during installation if you enable option "Request user authorization (OAuth) during installation" in your github app. This way user not only install your github app but also will authorize your github app.

What is the difference between a GitHub App and the REST API for GitHub?

What is the difference between a GitHub App and the REST API for GitHub? Why would you need a GitHub App if you can just use the REST API, without setting any environment up?
The REST API should just be a collection of endpoints that accept a POST along with access tokens. But the GitHub App requires cloning an entire repo written in Ruby, that has nothing to do with my app.
I am not looking for users to integrate with my repo, I want them to be able to connect their own repo to the application.
But the GitHub App requires cloning an entire repo written in Ruby, that has nothing to do with my app.
I don't believe this is true.
GitHub Apps make the process of integrating 3rd party tools into your GitHub repositories smoother.
GitHub Apps are installed by organizations and granted access to specific repositories via GitHub. For example, CodeClimate is a tool which performs checks on pull requests. Rather than granting them OAuth access to my repositories, I can install the CodeClimate GitHub App on my organization and configure which repositories they have access to. I can see all the apps installed and what their permissions are.
Note that "installing" a GitHub App does not install any code. "Installing" gives the app permissions for the service to access your organization and repos. A GitHub App is a wrapper around an existing service.
If you want users to connect their repos to your application, consider a GitHub App.
This is covered in About apps.
An OAuth App acts as a GitHub user, whereas a GitHub App uses its own identity when installed on an organization or on repositories within an organization.
GitHub Apps are the officially recommended way to integrate with GitHub because they offer much more granular permissions to access data, but GitHub supports both OAuth Apps and GitHub Apps.
GitHub Apps are first-class actors within GitHub. A GitHub App acts on its own behalf, taking actions via the API directly using its own identity, which means you don't need to maintain a bot or service account as a separate user.
GitHub Apps can be installed directly on organizations and user accounts and granted access to specific repositories. They come with built-in webhooks and narrow, specific permissions. When you set up your GitHub App, you can select the repositories you want it to access. For example, you can set up an app called MyGitHub that writes issues in the octocat repository and only the octocat repository. To install a GitHub App, you must be an organization owner or have admin permissions in a repository.
GitHub Apps are applications that need to be hosted somewhere. For step-by-step instructions that cover servers and hosting, see "Building Your First GitHub App."
Differences between GitHub Apps and OAuth Apps has a complete breakdown.

Should GitHub Pages https:<moniker>.github.io/<repo> point to Read-the-docs build?

I have a GitHub repo of docs linked to my RTD account. The GitHub/RTD connection appears to be set up correctly with a functional webhook (green checks at both ends). Commits to the repo trigger a successful build on RTD as expected. RTD is an Authorized OAuth App and my RTD account is connected to my GitHub account.
Under Settings -> GitHub pages, I have tried both master branch and master branch/docs. I would expect https://moniker.github.io/repo-name/ to go to the connected RTD docs. But it just shows the repo-name/README.md file, not the repo-name.rtfd.io docs. Am I misunderstanding the linkage or the use of GitHub Pages? Or am I completely missing something? Thanks for any insight.
I put in a help desk question to GitHub and their response was:
GitHub Pages provides its own web hosting and will not integrate with external services. If you're publishing your site elsewhere GitHub Pages will not link to it.
So the answer is "no", adding the webhook only triggers a new build on commits and I do explicitly need a docs/index.html (or .md) that redirects to the RTD documentation.

How can I programmatically add resources to a GitHub Page?

I have a GitHub App set up to pull some data, authenticate with an installation token, and commit it to the associated repository every day. I would like this new data to be available on the GitHub Pages site for the repo which requires a GitHub Pages build. The GitHub App has read & write privs assigned on "Repository contents" and "Pages".
It appears that the daily commit is attempting to rebuild the page as in the repository's GitHub Pages settings after the daily commit I see:
Your site is having problems building: Page build failed.
An empty commit with my primary account (not the GitHub App) after a failed build triggers a successful rebuild as seen below.
October 23-25, 2018:
https://github.com/btouellette/HHHFreshBotRedux/commits/master
Nothing in the GitHub documentation about these generic build failures (https://help.github.com/articles/generic-jekyll-build-failures/) appears relevant as I am not using a deploy key, the primary account the GitHub App is installed on has a verified e-mail address, and I'm only pushing static files and not using Jekyll at all.
Since I'm already authenticating with the GitHub API to commit the file I attempted to utilize the API endpoint to manually request a page build (https://developer.github.com/v3/repos/pages/#request-a-page-build). The documentation says this endpoint is enabled for GitHub Apps but when I attempt to call it I get the response "Resource not accessible by integration".
Is there some way to address the build failures, to get the page build API endpoint working with the GitHub App, or to find another way to make new files available on the GitHub Pages site progammatically?
By using 'basic' authentication in octokit and providing explicit user and password I'm able to successfully request a pages build. The build endpoint is enabled for GitHub Apps but only for user-to-server requests where the app is acting as a user with user credentials.
Alternately I found that I can reference the raw content in the GitHub repository directly rather than using relative links from within the GitHub Pages site. This works but having the files in the pages build is better as they are served via CDN.
So by using full URLs like:
https://raw.githubusercontent.com/btouellette/HHHFreshBotRedux/master/docs/daily/20181025.json
Instead of relative URLs for the GitHub Pages site like:
"daily/20181025.json"
I'm able to grab files in Javascript that have not been added to the GitHub Pages build but have been made available in the repository and use them to build out the site dynamically.

How to link GitHub repository with JIRA project?

I have a software project in JIRA and want to link that project with a GitHub repository so that when I create tasks in the JIRA project I can branch out in the corresponding GitHub repository, etc. I was able to link my GitHub account with my JIRA account (https://confluence.atlassian.com/adminjiracloud/connect-jira-cloud-to-github-814188429.html) but I don't know how to connect one of my JIRA projects with a specific GitHub repository.
For example, when I create a task in my JIRA project I expect to see a link on the task page to create a branch. There's no such links because the project is not linked to a repository.
EDIT: I don't see the Development panel on the issue page in JIRA. If I were able to see that panel that would solve this problem (likely).
EDIT: I am trying to see this panel on the issue page. This is from JIRA's help pages.
EDIT: Instead I see this (notice no Development panel on the right side that allows me to create a branch)
Step 1. Create an OAuth access token for your GitHub account
Log in to GitHub as a user with admin permissions on the account.
Choose Edit Your Profile.
Select OAuth Applications.
Select the Developer Applications tab.
Choose Register new OAuth application.
Enter a name for Application Name.
Enter the JIRA Software URL for both the URL and Callback URL fields. Press Register Application.
Keep your browser open at your GitHub account while you go on with the next step.
Step 2. Add the OAuth token in JIRA Software
Log in to JIRA Software as a user with admin permissions.
From the JIRA Software dashboard click the cog (settings) icon.
Choose Applications.
From the Integrations section on the left, choose DVCS accounts.
Click Link Bitbucket Cloud or GitHub account.
Choose 'GitHub' as the Host value.
Enter a Team or User Account name.
Copy the Client ID and Client Secret values from your GitHub site into the dialog.
Leave the default auto link and Smart Commits (recommended) as is or change them
Click Add.
Grant access when prompted
When JIRA connects successfully, you'll see your account on the 'DVCS accounts' page.