Skip to content

[WIP] Update PR squash guard workflow to English - #297

Closed
janrysavy with Copilot wants to merge 1 commit into
mainfrom
copilot/update-pr-squash-guard-workflow
Closed

janrysavy with Copilot wants to merge 1 commit into
mainfrom
copilot/update-pr-squash-guard-workflow

Conversation

Copilot AI commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

Rewrite the existing PR squash guard workflow to English and open a new PR with the changes.

Context:

  • There is already a workflow file introduced in a prior PR at .github/workflows/pr-squash-guard.yml that checks PR commit counts and fails for specific authors when there are more than one commit.

Task:

  • Ensure a workflow exists at .github/workflows/pr-squash-guard.yml that enforces: any pull request authored by GitHub users "Lemi257" or "bellus869" must have exactly one commit. If the PR has more than one commit, the job fails.
  • Rewrite all workflow names, job/step names, log messages, and the failure message to English.
  • Keep functionality unchanged (same authors, same event triggers, same minimal permissions, robust for PRs from forks). Use actions/github-script with the REST API to fetch commit count when not present in the payload.
  • If the file already exists, update it in-place; if it doesn't, create it.
  • Open a new PR with the English naming and messaging.

Workflow requirements:

  • File path: .github/workflows/pr-squash-guard.yml
  • Triggers: pull_request with types [opened, synchronize, reopened, ready_for_review, edited]
  • Permissions: contents: read, pull-requests: read
  • Job name (English): "Check commit count for selected authors"
  • Step name (English): "Check commit count and fail if necessary"
  • Authors list: ["Lemi257", "bellus869"]
  • Failure message (English): "This pull request must be squashed into a single commit. Found {commits} commit(s)."
  • Informational logs in English.

Suggested implementation (you may adopt as-is):

name: PR squash guard

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, edited]

permissions:
contents: read
pull-requests: read

jobs:
check-commits:
name: Check commit count for selected authors
runs-on: ubuntu-latest
steps:
- name: Check commit count and fail if necessary
uses: actions/github-script@v7
with:
script: |
const targetAuthors = ["Lemi257", "bellus869"]; // PRs by these authors must be squashed to 1 commit
const pr = context.payload.pull_request;
const author = pr?.user?.login;
const number = pr?.number;

        if (!author || !number) {
          core.info("Unable to determine author or PR number — skipping check.");
          return;
        }

        if (!targetAuthors.includes(author)) {
          core.info(`Author ${author} is not in the target list — check does not apply.`);
          return;
        }

        let commits = typeof pr.commits === 'number' ? pr.commits : undefined;
        if (typeof commits !== 'number') {
          const { data: prData } = await github.rest.pulls.get({
            owner: context.repo.owner,
            repo: context.repo.repo,
            pull_number: number,
          });
          commits = prData.commits;
        }

        core.info(`PR #${number} by ${author} has ${commits} commit(s).`);

        if (commits > 1) {
          core.setFailed(`This pull request must be squashed into a single commit. Found ${commits} commit(s).`);
        } else {
          core.info("Commit count is OK (<= 1).");
        }

PR details:

  • Branch name suggestion: chore/workflow-pr-squash-guard-en
  • PR title: "Add PR squash guard workflow for specific authors (English)"
  • PR description: Explain in English that the workflow runs on pull_request events, checks the number of commits specifically for authors Lemi257 and bellus869, and fails if there is more than one commit to enforce squash merges for those authors.

This pull request was created as a result of the following prompt from Copilot chat.

Rewrite the existing PR squash guard workflow to English and open a new PR with the changes.

Context:

  • There is already a workflow file introduced in a prior PR at .github/workflows/pr-squash-guard.yml that checks PR commit counts and fails for specific authors when there are more than one commit.

Task:

  • Ensure a workflow exists at .github/workflows/pr-squash-guard.yml that enforces: any pull request authored by GitHub users "Lemi257" or "bellus869" must have exactly one commit. If the PR has more than one commit, the job fails.
  • Rewrite all workflow names, job/step names, log messages, and the failure message to English.
  • Keep functionality unchanged (same authors, same event triggers, same minimal permissions, robust for PRs from forks). Use actions/github-script with the REST API to fetch commit count when not present in the payload.
  • If the file already exists, update it in-place; if it doesn't, create it.
  • Open a new PR with the English naming and messaging.

Workflow requirements:

  • File path: .github/workflows/pr-squash-guard.yml
  • Triggers: pull_request with types [opened, synchronize, reopened, ready_for_review, edited]
  • Permissions: contents: read, pull-requests: read
  • Job name (English): "Check commit count for selected authors"
  • Step name (English): "Check commit count and fail if necessary"
  • Authors list: ["Lemi257", "bellus869"]
  • Failure message (English): "This pull request must be squashed into a single commit. Found {commits} commit(s)."
  • Informational logs in English.

Suggested implementation (you may adopt as-is):

name: PR squash guard

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, edited]

permissions:
contents: read
pull-requests: read

jobs:
check-commits:
name: Check commit count for selected authors
runs-on: ubuntu-latest
steps:
- name: Check commit count and fail if necessary
uses: actions/github-script@v7
with:
script: |
const targetAuthors = ["Lemi257", "bellus869"]; // PRs by these authors must be squashed to 1 commit
const pr = context.payload.pull_request;
const author = pr?.user?.login;
const number = pr?.number;

        if (!author || !number) {
          core.info("Unable to determine author or PR number — skipping check.");
          return;
        }

        if (!targetAuthors.includes(author)) {
          core.info(`Author ${author} is not in the target list — check does not apply.`);
          return;
        }

        let commits = typeof pr.commits === 'number' ? pr.commits : undefined;
        if (typeof commits !== 'number') {
          const { data: prData } = await github.rest.pulls.get({
            owner: context.repo.owner,
            repo: context.repo.repo,
            pull_number: number,
          });
          commits = prData.commits;
        }

        core.info(`PR #${number} by ${author} has ${commits} commit(s).`);

        if (commits > 1) {
          core.setFailed(`This pull request must be squashed into a single commit. Found ${commits} commit(s).`);
        } else {
          core.info("Commit count is OK (<= 1).");
        }

PR details:

  • Branch name suggestion: chore/workflow-pr-squash-guard-en
  • PR title: "Add PR squash guard workflow for specific authors (English)"
  • PR description: Explain in English that the workflow runs on pull_request events, checks the number of commits specifically for authors Lemi257 and bellus869, and fails if there is more than one commit to enforce squash merges for those authors.

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@janrysavy
janrysavy marked this pull request as ready for review October 9, 2025 19:02
Copilot AI requested a review from janrysavy October 9, 2025 19:05
@janrysavy janrysavy closed this Oct 9, 2025
@janrysavy
janrysavy deleted the copilot/update-pr-squash-guard-workflow branch April 10, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants