Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aircall/ci-scripts

Package Overview
Dependencies
Maintainers
7
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aircall/ci-scripts - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

2

ci-scripts.js

@@ -182,3 +182,3 @@ #!/usr/bin/env node

const previousRelease = options.fromCircleCISha1
? await getPreviousReleaseFromSha1()
? await getPreviousReleaseFromSha1(process.env['CIRCLE_SHA1'])
: await getPreviousRelease();

@@ -185,0 +185,0 @@

@@ -7,2 +7,3 @@ const { post } = require('../request.js');

getPreviousReleaseFromRelease,
getPreviousReleaseFromSha1,
getLatestDraft

@@ -36,4 +37,4 @@ } = require('../github.js');

short
}
}
};
};

@@ -47,50 +48,45 @@ /**

const generateCommonPayload = (environment, tagName) => {
const payload = []
const { LINK_LOGS_PHONE } = checkEnvVariables([`LINK_LOGS_PHONE`])
const {LINK_PERFORMANCES_PHONE} = checkEnvVariables([`LINK_PERFORMANCES_PHONE`])
const { LINK_SENTRY_PHONE } = checkEnvVariables([`LINK_SENTRY_PHONE`])
const payload = [];
const { LINK_LOGS_PHONE } = checkEnvVariables([`LINK_LOGS_PHONE`]);
const { LINK_PERFORMANCES_PHONE } = checkEnvVariables([`LINK_PERFORMANCES_PHONE`]);
const { LINK_SENTRY_PHONE } = checkEnvVariables([`LINK_SENTRY_PHONE`]);
if (LINK_LOGS_PHONE){
if (LINK_LOGS_PHONE) {
let url = LINK_LOGS_PHONE + environment;
if (environment === 'production') {
url += `+-%40user_session.company_id%3A173377` // removing logs from AIRCALL - ROUTING BETA company
url += `+%40user_session.release%3A${tagName}`
url += `+-%40user_session.company_id%3A173377`; // removing logs from AIRCALL - ROUTING BETA company
url += `+%40user_session.release%3A${tagName}`;
}
payload.push(buildAttachmentField(
':datadog: App logs',
`<${url}|Link>`
))
payload.push(buildAttachmentField(':datadog: App logs', `<${url}|Link>`));
}
if (environment === 'production' && LINK_PERFORMANCES_PHONE){
payload.push(buildAttachmentField(
':datadog: Monitoring dashboard',
`<${LINK_PERFORMANCES_PHONE}|Link>`
))
if (environment === 'production' && LINK_PERFORMANCES_PHONE) {
payload.push(
buildAttachmentField(':datadog: Monitoring dashboard', `<${LINK_PERFORMANCES_PHONE}|Link>`)
);
}
if (LINK_SENTRY_PHONE) {
payload.push(buildAttachmentField(
':sentry: JS Errors',
`<${LINK_SENTRY_PHONE}${environment}|Link>`
))
payload.push(
buildAttachmentField(':sentry: JS Errors', `<${LINK_SENTRY_PHONE}${environment}|Link>`)
);
}
return payload;
}
};
const generateStagingPayload = (mergedPR, lastDraft, circleId, project) => {
const payload = [
buildAttachmentField(
'PR',
`[<${mergedPR.url}|#${mergedPR.number}>] ${mergedPR.title}, by *@${
mergedPR.author.login
}*`,
'PR',
`[<${mergedPR.url}|#${mergedPR.number}>] ${mergedPR.title}, by *@${mergedPR.author.login}*`,
false
),
buildAttachmentField('Associated Release', `<${lastDraft.html_url}|${lastDraft.tag_name}>`),
buildAttachmentField('CircleCI Workflow', `<https://circleci.com/workflow-run/${circleId}|Link>`)
buildAttachmentField(
'CircleCI Workflow',
`<https://circleci.com/workflow-run/${circleId}|Link>`
)
];

@@ -112,5 +108,3 @@

title: 'Diff',
value: `<https://github.com/${project}/compare/${prevTag.tag_name}...${lastTag.tag_name}|${
prevTag.tag_name
}...${lastTag.tag_name}>`,
value: `<https://github.com/${project}/compare/${prevTag.tag_name}...${lastTag.tag_name}|${prevTag.tag_name}...${lastTag.tag_name}>`,
short: true

@@ -125,13 +119,3 @@ }

const getPRData = async commitish => {
const prs = await getMergedPullRequests();
const mergedPR = prs.find(pr => {
return pr.mergeCommit.oid === commitish;
});
return mergedPR;
};
const notifySlack = async (environment, channel, title = ':ship:') => {
const generateReleasePayload = async environment => {
const project = CIRCLE_PROJECT_USERNAME + '/' + CIRCLE_PROJECT_REPONAME;

@@ -152,5 +136,41 @@

const messageTitle = `${title} ${environment.charAt(0).toUpperCase() +
environment.slice(1)} deployment`;
return fields;
};
const generateRollbackPayload = async () => {
const currentRelease = await getReleaseFromSha1(CIRCLE_SHA1);
const previousRelease = await getPreviousReleaseFromSha1(CIRCLE_SHA1);
const payload = [
{
title: `Reverted`,
value: `from <${currentRelease.html_url} | ${currentRelease.tag_name}> to <${previousRelease.html_url} | ${previousRelease.tag_name}>`
}
];
const commonPayload = generateCommonPayload('production', currentRelease.tag_name);
return [...payload, ...commonPayload];
};
const getPRData = async commitish => {
const prs = await getMergedPullRequests();
const mergedPR = prs.find(pr => {
return pr.mergeCommit.oid === commitish;
});
return mergedPR;
};
const notifySlack = async (environment, channel, title = ':ship:') => {
const isRollback = title === 'rollback';
const messageTitle = isRollback
? `:alert: ${environment.charAt(0).toUpperCase() + environment.slice(1)} rollback`
: `${title} ${environment.charAt(0).toUpperCase() + environment.slice(1)} deployment`;
const fields = isRollback
? await generateRollbackPayload()
: await generateReleasePayload(environment);
const payload = JSON.stringify({

@@ -157,0 +177,0 @@ channel,

@@ -113,6 +113,6 @@ const { get, patch, post } = require('./request.js');

const releases = await getReleases();
const release = releases.findIndex(r => {
const index = releases.findIndex(r => {
return r.target_commitish === commitish;
});
return release[index + 1];
return releases[index + 1];
};

@@ -119,0 +119,0 @@

{
"name": "@aircall/ci-scripts",
"version": "2.3.0",
"version": "2.4.0",
"dependencies": {},

@@ -5,0 +5,0 @@ "main": "ci-scripts.js",

@@ -231,1 +231,29 @@ # CI Scripts

```
For a rollback message
```yml
jobs:
slack-notify:
executor: node
parameters:
env:
type: string
channel:
type: string
steps:
- *restore-workspace
- run: npx @aircall/ci-scripts notify-slack << parameters.env >> << parameters.channel >> << parameters.title >>
workflows:
version: 2
build-deploy:
jobs:
- checkout-install-dependencies
- slack-notify:
requires: [checkout-install-dependencies]
filters: *branch-filter
env: production
channel: aircall-xyz
title: rollback
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc