GitHub webhook: Only unfreeze/refreeze if actually frozen. (#5182)

Complements https://github.com/fleetdm/fleet/pull/5181

Related to https://github.com/fleetdm/fleet/issues/5179
This commit is contained in:
Mike McNeil 2022-04-15 19:30:59 -05:00 committed by GitHub
parent 69f8f7da8f
commit 7bc16c9b36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,18 +278,22 @@ module.exports = {
// And also unfreeze and re-freeze to temporarily allow merging.
// [?] https://github.com/fleetdm/fleet/issues/5179
if (isAutoApproved) {
await sails.helpers.http.post('https://www.mergefreeze.com/api/branches/fleetdm/fleet/main', { frozen: false, access_token: sails.config.custom.mergeFreezeAccessToken, user_name: 'fleet-release' });//eslint-disable-line camelcase
// Then, in the background, 2 minutes later...
setTimeout(()=>{
sails.helpers.http.post('https://www.mergefreeze.com/api/branches/fleetdm/fleet/main', { frozen: true, access_token: sails.config.custom.mergeFreezeAccessToken, user_name: 'fleet-release' })//eslint-disable-line camelcase
.exec((err)=>{
if (err) {
sails.log.error('Background instruction failed: Unexpected error re-freezing repo (see https://github.com/fleetdm/fleet/issues/5179 for background):', err);
}
sails.log.info('Re-freeze completed successfully.');
});//_∏_
}, 2*60*1000);//_∏_
let mergeFreezeReport = await sails.helpers.http.get('https://www.mergefreeze.com/api/branches/fleetdm/fleet/main', { access_token: sails.config.custom.mergeFreezeAccessToken });//eslint-disable-line camelcase
if (mergeFreezeReport.frozen) {
await sails.helpers.http.post('https://www.mergefreeze.com/api/branches/fleetdm/fleet/main', { frozen: false, access_token: sails.config.custom.mergeFreezeAccessToken, user_name: 'fleet-release' });//eslint-disable-line camelcase
// Then, in the background, 2 minutes later...
setTimeout(()=>{
sails.helpers.http.post('https://www.mergefreeze.com/api/branches/fleetdm/fleet/main', { frozen: true, access_token: sails.config.custom.mergeFreezeAccessToken, user_name: 'fleet-release' })//eslint-disable-line camelcase
.exec((err)=>{
if (err) {
sails.log.error('Background instruction failed: Unexpected error re-freezing repo (see https://github.com/fleetdm/fleet/issues/5179 for background):', err);
}
sails.log.info('Re-freeze completed successfully.');
});//_∏_
}, 2*60*1000);//_∏_
}//fi
}//fi