diff --git a/Dockerfile b/Dockerfile index 5c2fcdf5..6c8edb02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:20-alpine WORKDIR /opt/safe-settings -ENV NODE_ENV production +ENV NODE_ENV=production ## Set the Labels LABEL version="1.0" \ description="Probot app which is a modified version of Settings Probot GitHub App" \ @@ -22,4 +22,4 @@ USER node ## This does not start properly when using the ['npm','start'] format ## so stick with just calling it outright -CMD npm start +CMD ["npm", "start"] diff --git a/index.js b/index.js index f6af26b5..be2917ec 100644 --- a/index.js +++ b/index.js @@ -572,10 +572,10 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) => robot.log.debug(`Updating check run ${JSON.stringify(params)}`) await context.octokit.checks.update(params) - // guarding against null value from upstream libary that is - // causing a 404 and the check to stall - // from issue: https://github.com/github/safe-settings/issues/185#issuecomment-1075240374 - if (check_suite.before === '0000000000000000000000000000000000000000') { + if (env.PR_USE_BASE_SHA === 'true') { + check_suite.before = check_suite.pull_requests[0].base.sha + robot.log.debug(`Using PR's base sha: ${check_suite.before}...${check_suite.after}`) + } else if (check_suite.before === '0000000000000000000000000000000000000000') { check_suite.before = check_suite.pull_requests[0].base.sha } params = Object.assign(context.repo(), { basehead: `${check_suite.before}...${check_suite.after}` }) diff --git a/lib/env.js b/lib/env.js index 94c0ea74..9d30f850 100644 --- a/lib/env.js +++ b/lib/env.js @@ -4,6 +4,7 @@ module.exports = { SETTINGS_FILE_PATH: process.env.SETTINGS_FILE_PATH || 'settings.yml', DEPLOYMENT_CONFIG_FILE_PATH: process.env.DEPLOYMENT_CONFIG_FILE || 'deployment-settings.yml', CREATE_PR_COMMENT: process.env.CREATE_PR_COMMENT || 'true', + PR_USE_BASE_SHA: process.env.PR_USE_BASE_SHA || 'false', CREATE_ERROR_ISSUE: process.env.CREATE_ERROR_ISSUE || 'true', BLOCK_REPO_RENAME_BY_HUMAN: process.env.BLOCK_REPO_RENAME_BY_HUMAN || 'false', FULL_SYNC_NOP: process.env.FULL_SYNC_NOP === 'true' diff --git a/lib/plugins/rulesets.js b/lib/plugins/rulesets.js index b77ead1b..569f0615 100644 --- a/lib/plugins/rulesets.js +++ b/lib/plugins/rulesets.js @@ -15,7 +15,7 @@ const version = { 'X-GitHub-Api-Version': '2022-11-28' } module.exports = class Rulesets extends Diffable { - constructor (nop, github, repo, entries, log, errors, scope) { + constructor(nop, github, repo, entries, log, errors, scope) { super(nop, github, repo, entries, log, errors) this.github = github this.repo = repo @@ -28,7 +28,7 @@ module.exports = class Rulesets extends Diffable { // Find all Rulesets for this org find () { if (this.scope === 'org') { - this.log.debug(`Getting all rulesets for the org ${this.org}`) + this.log.debug(`Getting all rulesets for the org ${this.repo.owner}`) const listOptions = this.github.request.endpoint.merge('GET /orgs/{org}/rulesets', { org: this.repo.owner, diff --git a/lib/settings.js b/lib/settings.js index 20e71167..0a9c30ec 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -18,6 +18,7 @@ class Settings { static async syncAll (nop, context, repo, config, ref) { const settings = new Settings(nop, context, repo, config, ref) try { + settings.log.debug('Starting syncAll') await settings.loadConfigs() // settings.repoConfigs = await settings.getRepoConfigs() await settings.updateOrg() @@ -33,6 +34,7 @@ class Settings { static async syncSubOrgs (nop, context, suborg, repo, config, ref) { const settings = new Settings(nop, context, repo, config, ref, suborg) try { + settings.log.debug('Starting syncSubOrgs') await settings.loadConfigs() await settings.updateAll() await settings.handleResults() @@ -45,6 +47,7 @@ class Settings { static async sync (nop, context, repo, config, ref) { const settings = new Settings(nop, context, repo, config, ref) try { + settings.log.debug('Starting sync') await settings.loadConfigs(repo) if (settings.isRestricted(repo.repo)) { return