mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-16 09:36:26 +00:00
34 lines
926 B
JavaScript
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
|
|
);
|
|
}
|
|
}
|