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

SP-520 add ARN webhook call to inform the Product Enablement team #19

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions action.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const core = require('@actions/core');
const Arn = require('./arn');
const Jira = require('./jira');

const jira = new Jira({
Expand All @@ -7,6 +8,13 @@ const jira = new Jira({
token: process.env.JIRA_TOKEN,
});

//Anne's ARN webhook url
const webhookUrl = 'https://arn.upraise.io/arn/executewebhook/44998/fd803c08-6778-43bb-a5fc-66a3768447ac';
const arn = new Arn({webhookUrl});

// 1. update JIRA issues
// 2. send a webhook to the ARN (Automated release notes) - JIRA app -
// with the componentName-tagName label
async function exec ({ issueIds, componentName, tagName, releaseDate }) {
try {
console.log({ issueIds, componentName, tagName, releaseDate });
Expand All @@ -30,6 +38,8 @@ async function exec ({ issueIds, componentName, tagName, releaseDate }) {
console.log(`Failed to update some Jira tickets: ${errors}`);
}

await arn.callWebhook( `${componentName}-${tagName}` );

} catch (error) {
console.error(error);
process.exit(1)
Expand Down
24 changes: 24 additions & 0 deletions arn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const fetch = require('node-fetch');

class Arn {
constructor ({ webhookUrl }) {
this.webhookUrl = webhookUrl || '';
}

async callWebhook(labelValue) {
const url = `${this.webhookUrl}?labelName=${labelValue}`
console.log(`Call webhook ${url}`);
const response = await fetch(url, {
method: 'GET',
headers: {},
});

if (!response.ok) {
const errorMsg = await response.text();

throw new Error(errorMsg)
}
}
}

module.exports = Arn;
Loading