Skip to content

feat: Add GITHUB_ACTION_MODE support for posting PR comments in GitHu…#923

Open
ctbui wants to merge 7 commits into
github:main-enterprisefrom
ctbui:feat/github-action-mode-pr-comments
Open

feat: Add GITHUB_ACTION_MODE support for posting PR comments in GitHu…#923
ctbui wants to merge 7 commits into
github:main-enterprisefrom
ctbui:feat/github-action-mode-pr-comments

Conversation

@ctbui

@ctbui ctbui commented Jan 26, 2026

Copy link
Copy Markdown

…b Actions

  • Add GITHUB_ACTION_MODE, GITHUB_REPOSITORY, and GITHUB_REF environment variables
  • Enable posting PR comments using GitHub Actions built-in env vars when running in action mode
  • Extract summary generation outside CREATE_PR_COMMENT condition for reuse
…b Actions

  - Add GITHUB_ACTION_MODE, GITHUB_REPOSITORY, and GITHUB_REF environment variables
  - Enable posting PR comments using GitHub Actions built-in env vars when running in action mode
  - Extract summary generation outside CREATE_PR_COMMENT condition for reuse

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a GITHUB_ACTION_MODE feature that allows safe-settings to post PR comments using GitHub Actions' built-in environment variables (GITHUB_REPOSITORY, GITHUB_REF) instead of relying on the existing CREATE_PR_COMMENT + check-suite payload flow.

Changes:

  • Adds GITHUB_ACTION_MODE, GITHUB_REPOSITORY, and GITHUB_REF to lib/env.js
  • Extracts the summary template outside the CREATE_PR_COMMENT conditional block and adds a new code path in handleResults that posts PR comments using GitHub Actions env vars
  • Documents the new action mode in docs/github-action.md

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/env.js Adds three new environment variable declarations for GitHub Action mode
lib/settings.js Moves summary generation before conditionals; adds GITHUB_ACTION_MODE branch to post PR comments via Actions env vars
docs/github-action.md Documents the new GITHUB_ACTION_MODE feature and adds it to the example workflow

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread lib/settings.js Outdated
Comment thread lib/env.js
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a GITHUB_ACTION_MODE feature that allows safe-settings to post PR comments using GitHub Actions built-in environment variables (GITHUB_REPOSITORY, GITHUB_REF) instead of relying on the existing CREATE_PR_COMMENT + check suite payload approach.

Changes:

  • Added GITHUB_ACTION_MODE, GITHUB_REPOSITORY, and GITHUB_REF to lib/env.js
  • Added logic in lib/settings.js to post PR comments via GitHub Actions env vars when GITHUB_ACTION_MODE is enabled, extracting the summary generation outside the CREATE_PR_COMMENT conditional
  • Added documentation for the new GitHub Action Mode in docs/github-action.md

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
lib/env.js Adds three new environment variables for GitHub Action mode
lib/settings.js Extracts summary outside CREATE_PR_COMMENT block; adds new code path to post PR comments using GHA env vars
docs/github-action.md Documents the new GITHUB_ACTION_MODE feature and adds example env var to workflow

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread lib/settings.js
Comment on lines +305 to +307
this.log.warn
? this.log.warn(`GITHUB_ACTION_MODE is set but GITHUB_REF ('${env.GITHUB_REF}') does not reference a pull request; skipping PR comment and continuing to complete check run.`)
: this.log.info(`GITHUB_ACTION_MODE is set but GITHUB_REF ('${env.GITHUB_REF}') does not reference a pull request; skipping PR comment and continuing to complete check run.`)
Comment thread lib/settings.js
Comment thread lib/env.js
Comment on lines +10 to +13
GITHUB_ACTION_MODE: process.env.GITHUB_ACTION_MODE === 'true',
// GitHub Actions built-in variables
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY || '', // format: owner/repo
GITHUB_REF: process.env.GITHUB_REF || '', // format: refs/pull/123/merge for PRs
Comment thread lib/settings.js Outdated
} catch (e) {
this.log.error(`Failed to post PR comment: ${e.message}`)
}
return
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a GITHUB_ACTION_MODE feature that enables safe-settings to post PR comments using GitHub Actions built-in environment variables (GITHUB_REPOSITORY and GITHUB_REF) instead of relying on the existing CREATE_PR_COMMENT mechanism tied to check suite payloads.

Changes:

  • Adds GITHUB_ACTION_MODE, GITHUB_REPOSITORY, and GITHUB_REF environment variables in lib/env.js
  • Extracts the summary generation outside the CREATE_PR_COMMENT conditional block and adds new logic to post PR comments when running in GitHub Action mode
  • Adds documentation for the new GitHub Action Mode feature

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
lib/env.js Adds three new environment variables for GitHub Action mode
lib/settings.js Moves summary generation before the conditional, adds GITHUB_ACTION_MODE branch to post PR comments via Actions env vars
docs/github-action.md Documents the new GITHUB_ACTION_MODE feature and adds it to the example workflow

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread lib/env.js
Comment on lines +10 to +13
GITHUB_ACTION_MODE: process.env.GITHUB_ACTION_MODE === 'true',
// GitHub Actions built-in variables
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY || '', // format: owner/repo
GITHUB_REF: process.env.GITHUB_REF || '', // format: refs/pull/123/merge for PRs

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Comment thread docs/github-action.md
Comment on lines +66 to +68
# Enable GitHub Action mode to post PR comments using built-in env vars
# GITHUB_REPOSITORY and GITHUB_REF are automatically injected by GitHub Actions
GITHUB_ACTION_MODE: true
Comment thread lib/settings.js
Comment on lines +305 to +315
this.log.warn
? this.log.warn(`GITHUB_ACTION_MODE is set but GITHUB_REF ('${env.GITHUB_REF}') does not reference a pull request; skipping PR comment and continuing to complete check run.`)
: this.log.info(`GITHUB_ACTION_MODE is set but GITHUB_REF ('${env.GITHUB_REF}') does not reference a pull request; skipping PR comment and continuing to complete check run.`)
}
} else if (env.GITHUB_ACTION_MODE && (!env.GITHUB_REPOSITORY || !env.GITHUB_REF)) {
const missingVars = [
!env.GITHUB_REPOSITORY && 'GITHUB_REPOSITORY',
!env.GITHUB_REF && 'GITHUB_REF'
].filter(Boolean).join(' and ')
const message = `GITHUB_ACTION_MODE is set but required environment variable(s) ${missingVars} are missing or empty; skipping PR comment and continuing to complete check run.`
this.log.warn ? this.log.warn(message) : this.log.info(message)
Comment thread lib/settings.js Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a GITHUB_ACTION_MODE feature that allows safe-settings to post PR comments using GitHub Actions built-in environment variables (GITHUB_REPOSITORY, GITHUB_REF) instead of relying solely on the existing CREATE_PR_COMMENT + check_suite payload path.

Changes:

  • Added three new environment variables (GITHUB_ACTION_MODE, GITHUB_REPOSITORY, GITHUB_REF) to lib/env.js
  • Extracted the summary template outside the CREATE_PR_COMMENT conditional in lib/settings.js and added new logic to post PR comments when GITHUB_ACTION_MODE is enabled
  • Added documentation for the GitHub Action Mode feature

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/env.js Adds GITHUB_ACTION_MODE (boolean), GITHUB_REPOSITORY, and GITHUB_REF env vars
lib/settings.js Extracts summary generation, adds GITHUB_ACTION_MODE comment-posting logic with error handling
docs/github-action.md Documents the new GitHub Action Mode and adds config to example workflow

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread lib/settings.js
Comment on lines +304 to +306
this.log.warn
? this.log.warn(`GITHUB_ACTION_MODE is set but GITHUB_REF ('${env.GITHUB_REF}') does not reference a pull request; skipping PR comment and continuing to complete check run.`)
: this.log.info(`GITHUB_ACTION_MODE is set but GITHUB_REF ('${env.GITHUB_REF}') does not reference a pull request; skipping PR comment and continuing to complete check run.`)
Comment thread docs/github-action.md
Comment on lines +66 to +67
# Enable GitHub Action mode to post PR comments using built-in env vars
# GITHUB_REPOSITORY and GITHUB_REF are automatically injected by GitHub Actions
Comment thread lib/env.js
Comment on lines +10 to +13
GITHUB_ACTION_MODE: process.env.GITHUB_ACTION_MODE === 'true',
// GitHub Actions built-in variables
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY || '', // format: owner/repo
GITHUB_REF: process.env.GITHUB_REF || '', // format: refs/pull/123/merge for PRs

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

@decyjphr

Copy link
Copy Markdown
Collaborator

@copilot add tests for the new feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants