Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 18, 2025

Overview

This PR adds the ability to sync .gitignore files across multiple repositories via pull requests, similar to how dependabot.yml syncing works. This addresses the feature request in #[issue_number] to sync gitignore files while allowing repository-specific variances.

Key Features

1. New Input Parameters

  • gitignore: Path to a .gitignore file to sync to target repositories
  • gitignore-pr-title: Title for pull requests when updating .gitignore (default: chore: update .gitignore)

2. Repository-Specific Content Preservation

The implementation includes a unique feature to preserve repository-specific entries at the end of .gitignore files. Content after a # Repository-specific entries (preserved during sync) marker is kept intact during syncs, allowing you to maintain bulk consistency while supporting repo-specific exceptions.

Example:

# Standard entries (synced from source)
node_modules/
dist/
*.log

# Repository-specific entries (preserved during sync)
scanresults.json
twistlock-*.md

When syncing, the standard entries are updated from the source file while scanresults.json and twistlock-*.md remain untouched in the target repository.

3. Usage Examples

Basic usage:

- name: Sync .gitignore
  uses: joshjohanning/bulk-github-repo-settings-sync-action@v1
  with:
    github-token: ${{ steps.app-token.outputs.token }}
    repositories-file: 'repos.yml'
    gitignore: './config/gitignore/.gitignore'
    gitignore-pr-title: 'chore: update .gitignore'

Per-repository overrides:

repos:
  - repo: owner/repo1
    gitignore: './config/gitignore/node.gitignore'
  - repo: owner/repo2
    gitignore: './config/gitignore/python.gitignore'
  - repo: owner/repo3
    gitignore: './.gitignore' # use this repo's .gitignore

Implementation Details

  • syncGitignore function: Mirrors the syncDependabotYml implementation pattern for consistency
  • Smart content merging: Automatically detects and preserves repo-specific content
  • PR management: Creates new PRs or detects existing ones to avoid duplicates
  • Verified commits: Uses GitHub API for commit creation, ensuring verified status
  • Dry-run support: Preview changes without applying them
  • Comprehensive error handling: Gracefully handles missing files, API errors, and permission issues

Testing

Added 9 new test cases covering:

  • Creating .gitignore when it doesn't exist
  • Updating .gitignore when content differs
  • Preserving repository-specific content
  • Skipping when content is unchanged
  • Detecting existing PRs
  • Dry-run mode
  • Error scenarios (invalid format, missing file, API errors)

All 51 tests pass

Documentation

  • Updated README with usage examples and behavior documentation
  • Added to features list
  • Updated authentication requirements (requires Contents and Pull Requests permissions)
  • Included example .gitignore file and YAML configuration

Version

Bumped version from 1.1.1 to 1.2.0 (minor version bump for new feature)

Related Issues

Fixes #[issue_number]

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • img.shields.io
    • Triggering command: node /home/REDACTED/work/bulk-github-repo-settings-sync-action/bulk-github-repo-settings-sync-action/node_modules/.bin/make-coverage-badge-better --label-color #333 --output-path ./badges/coverage.svg (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add ability to sync gitignore</issue_title>
<issue_description>Sync gitignore by repo just like dependabot</issue_description>

Comments on the Issue (you are @copilot in this section)

@joshjohanning Require the bulk to be the same but allow for some variances at the end, like this with the twistlock config

Image</comment_new>

Fixes #14


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

Copilot AI self-assigned this Oct 18, 2025
Copilot AI and others added 3 commits October 18, 2025 16:32
Co-authored-by: joshjohanning <19912012+joshjohanning@users.noreply.github.com>
- Add gitignore and gitignore-pr-title inputs to action.yml
- Implement syncGitignore function to sync .gitignore files
- Support preserving repo-specific content at end with marker comment
- Integrate gitignore sync into main workflow
- Add comprehensive tests for gitignore sync functionality
- Update README with usage examples and documentation
- Increment version to 1.2.0

Co-authored-by: joshjohanning <19912012+joshjohanning@users.noreply.github.com>
Co-authored-by: joshjohanning <19912012+joshjohanning@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ability to sync gitignore by repository Add ability to sync .gitignore files across repositories with repo-specific preservation Oct 18, 2025
Copilot AI requested a review from joshjohanning October 18, 2025 16:48
Copilot finished work on behalf of joshjohanning October 18, 2025 16:48
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.

Add ability to sync gitignore

2 participants