Skip to content

Conversation

@mcdonnnj
Copy link
Member

@mcdonnnj mcdonnnj commented Feb 11, 2026

🗣 Description

This pull request updates the blacken.yml workflow to use a PAT when checking out the repository and to only run when Python files have changed.

💭 Motivation and context

This PAT will allow a commit pushed up after auto-formatting to trigger other workflows in the repository. This will ensure that checks are run in pull requests. Only running if Python files have changed just makes sense since the workflow is to auto-format Python code.

🧪 Testing

👀 I also pushed some test commits and verified functionality (they have since been rebased out).

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All new and existing tests pass.

Provide a PAT when checking out the repository in the `blacken.yml`
workflow. This will allow a commit pushed by this workflow to trigger
other workflows in the repository.
@mcdonnnj mcdonnnj self-assigned this Feb 11, 2026
@mcdonnnj mcdonnnj added the improvement This issue or pull request will add or improve functionality, maintainability, or ease of use label Feb 11, 2026
@mcdonnnj mcdonnnj requested a review from Copilot February 11, 2026 19:42
@github-actions github-actions bot added github-actions Pull requests that update GitHub Actions code python Pull requests that update Python code labels Feb 11, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the repository’s auto-format (“blacken”) GitHub Actions workflow so that commits pushed by the formatter can trigger other workflows (by using a PAT for checkout/push authentication).

Changes:

  • Configure actions/checkout in blacken.yml to use a PAT secret.
  • Minor formatting-only adjustment in cyhy/core/common.py (export list formatting).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cyhy/core/common.py Formatting-only change in __all__ exports list.
.github/workflows/blacken.yml Uses a PAT for checkout to allow auto-format pushes to trigger subsequent workflows.

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

@mcdonnnj
Copy link
Member Author

mcdonnnj commented Feb 11, 2026

I plan on rebasing to remove any test commits I used to verify expected behavior before merging the PR.

Copy link
Member

@dav3r dav3r left a comment

Choose a reason for hiding this comment

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

Good stuff 👍

@mcdonnnj mcdonnnj changed the title Use a PAT when auto-blackening Update the configuration of the blacken.yml workflow Feb 11, 2026
mcdonnnj and others added 2 commits February 11, 2026 15:17
In forks the secret will not be available so we should fall back on
`github.token`. This will allow the workflow to run cleanly even if the
pushed commit does not trigger other workflows.

Co-authored-by: Copilot <[email protected]>
Adjust the trigger configuration to only run on pull requests that
modify Python files.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment on lines 5 to +7
pull_request:
paths:
- '**.py'
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

on.pull_request.paths filters out PRs that only modify this workflow file, so changes to blacken.yml won’t exercise the workflow in CI. Consider including .github/workflows/blacken.yml (and possibly other formatting-related config files, if any) in the paths list so workflow changes still get validated.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

@mcdonnnj mcdonnnj Feb 11, 2026

Choose a reason for hiding this comment

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

I'm fine either way on this one.

Copy link
Member

Choose a reason for hiding this comment

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

After talking with @mcdonnnj, I agree with Copilot that it makes sense to include the workflow file here so it will be executed and we can verify that that changes to the workflow didn't break it.

Comment on lines +89 to +93
with:
# Needed by stefanzweifel/git-auto-commit-action to support the pull_request
# trigger.
ref: ${{ github.head_ref }}
token: ${{ secrets.GHA_AUTO_COMMIT_TOKEN || github.token }}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

With ref: ${{ github.head_ref }} and no repository: specified, actions/checkout will fail on PRs from forks because the head branch doesn’t exist in the base repo. If the goal is for the workflow to run on forked PRs (even if it can’t push), update checkout to use the PR head repo/SHA for forks and/or skip the auto-commit step when github.event.pull_request.head.repo.full_name != github.repository.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Please see fc8b6ad.

Using the stefanzweifel/git-auto-commit-action action in workflow runs
for pull requests from a fork is too much effort for something we will
be unlikely to need.

Co-authored-by: Copilot <[email protected]>
@mcdonnnj mcdonnnj requested review from dav3r and jsf9k February 11, 2026 20:43
Copy link
Member

@dav3r dav3r left a comment

Choose a reason for hiding this comment

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

LGTM, aside from the Copilot suggestion in https://github.com/cisagov/cyhy-core/pull/137/changes#r2795391409.

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

Labels

github-actions Pull requests that update GitHub Actions code improvement This issue or pull request will add or improve functionality, maintainability, or ease of use python Pull requests that update Python code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants