renovate/lib/workers/branch/status-checks.js
2019-01-08 05:44:56 +01:00

34 lines
926 B
JavaScript

const { appSlug, urls } = require('../../config/app-strings');
module.exports = {
setUnpublishable,
};
async function setUnpublishable(config) {
if (!config.unpublishSafe) {
return;
}
const context = `${appSlug}/unpublish-safe`;
const existingState = await platform.getBranchStatusCheck(
config.branchName,
context
);
// Set canBeUnpublished status check
const state = config.canBeUnpublished ? 'pending' : 'success';
const description = config.canBeUnpublished
? 'Packages < 24 hours old can be unpublished'
: 'Packages cannot be unpublished';
// Check if state needs setting
if (existingState === state) {
logger.debug('Status check is already up-to-date');
} else {
logger.debug(`Updating status check state to ${state}`);
await platform.setBranchStatus(
config.branchName,
context,
description,
state,
urls.documentation
);
}
}