@@ -64,13 +64,14 @@ public GithubAppCheck(final Namespace ns){
6464 * Method to verify whether the github app is installed on a repository or not.
6565 * @param fullRepoName = The repository full name, i.e, of the format "owner/repoName". Eg: "Salesforce/dockerfile-image-update"
6666 * @return True if github app is installed, false otherwise.
67+ * Reference: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app
6768 */
6869 protected boolean isGithubAppEnabledOnRepository (String fullRepoName ) {
6970 refreshJwtIfNeeded (appId , privateKeyPath );
7071 try {
71- // Return true if the app is found on the repository via JWT token and API call
72- // Reference: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app
73- gitHub .getApp ().getInstallationByRepository (fullRepoName . split ( "/" )[ 0 ], fullRepoName . split ( "/" )[ 1 ] );
72+ String org = fullRepoName . split ( "/" )[ 0 ];
73+ String repo = fullRepoName . split ( "/" )[ 1 ];
74+ gitHub .getApp ().getInstallationByRepository (org , repo );
7475 return true ;
7576 } catch (HttpException exception ) {
7677 if (exception .getResponseCode () != 404 ) {
@@ -93,7 +94,6 @@ protected boolean isGithubAppEnabledOnRepository(String fullRepoName) {
9394 private void refreshJwtIfNeeded (String appId , String privateKeyPath ) {
9495 if (jwt == null || jwtExpiry .isBefore (Instant .now ().minusSeconds (jwtRefreshBuffer ))) { // Adding a buffer to ensure token validity
9596 try {
96- // Generate JWT token 60 seconds before the expiry to continue Github app check
9797 generateJWT (appId , privateKeyPath );
9898 } catch (IOException | GeneralSecurityException exception ) {
9999 log .warn ("Could not refresh the JWT due to exception: {}" , exception .getMessage ());
0 commit comments