General overview of the flow
- When a user pushes changes to a repository
- The GitHub app will receive the push event and execute the code block within
- We will attempt to read the contents of our sample java project
- Parse the pom.xml for the java version
- Pass the Java version to JMS api
- Receive the payload and publish it as a new issue of the sample Java project
This article will go through in 3 parts
- Part 1: Create & install a GitHub application “java-runtime-check” using probot framework
- Part 2: Create & retrieve API credentials from Oracle Cloud
- Part 3: Run GitHub application on existing project
- Install packages
yarn add oci-sdk
yarn add oci-common
yarn add xml-parser
- Update index.js
/**
* This is the main entrypoint to your Probot app
* @param {import('probot').Probot} app
*/
const parse = require("xml-parser");
// JavaScript
const common = require("oci-common");
// Using default configurations
const provider = new common.ConfigFileAuthenticationDetailsProvider();
const jms = require("oci-jms");
const OWNER = "lanbau";
const REPO = "sample-java-project";
const PATH = "pom.xml";
module.exports = app => {
app.log.info("Yay, the app was loaded!");
app.on("push", async context => {
app.log.info({ event: context.name, action: context.payload.action });
try {
context.octokit.rest.repos
.getContent({
owner: OWNER,
repo: REPO,
path: PATH,
})
.then(res => {
const pomData = atob(res.data.content);
const obj = parse(pomData);
const javaVersion = obj.root.children[7].children[5].content;
const client = new jms.JavaManagementServiceClient({
authenticationDetailsProvider: provider,
});
(async () => {
try {
// Create a request and dependent object(s).
const getJavaReleaseRequest = {
releaseVersion: javaVersion,
opcRequestId: "GMT4UEGUMOLHIUHPFJNG123",
};
// Send request to the Client.
const getJavaReleaseResponse = await client.getJavaRelease(
getJavaReleaseRequest
);
context.octokit.rest.issues.create({
owner: OWNER,
repo: REPO,
title:
javaVersion +
" Security Baseline: " +
getJavaReleaseResponse.javaRelease.securityStatus,
body: `<ul>
<li>Release version: ${getJavaReleaseResponse.javaRelease.releaseVersion}</li>
<li>Family version: ${getJavaReleaseResponse.javaRelease.familyVersion}</li>
<li>Parent release version: ${getJavaReleaseResponse.javaRelease.parentReleaseVersion}</li>
<li>License type: ${getJavaReleaseResponse.javaRelease.licenseType}</li>
<li>Release date: ${getJavaReleaseResponse.javaRelease.releaseDate}</li>
<li>Release notes URL: ${getJavaReleaseResponse.javaRelease.releaseNotesUrl}</li>
</ul>`,
});
} catch (error) {
console.log("getJavaRelease Failed with error " + error);
}
})();
});
} catch (err) {
console.log(err);
}
});
};
- Update Permissions of GitHub application to read contents and listen to push event


- Go to sample-java-project & make a change


You can clone the sample project at https://github.com/lanbau/sample-java-project/
- Go to the demo project’s issues.
You will see that the GitHub application has automatically created an issue in the demo project.
There are more details within the issue description which is provided by Java Management Service.


This is the end of the GitHub app tutorial that demonstrate integration with Oracle’s Java Management Service.