Giter Club home page Giter Club logo

repo-file-sync-action's Introduction

Repo File Sync Action

Build CI GitHub David

Keep files like Action workflows or entire directories in sync between multiple repositories.

๐Ÿ‘‹ Introduction

With repo-file-sync-action you can sync files, like workflow .yml files, configuration files or whole directories between repositories or branches. It works by running a GitHub Action in your main repository everytime you push something to that repo. The action will use a sync.yml config file to figure out which files it should sync where. If it finds a file which is out of sync it will open a pull request in the target repository with the changes.

๐Ÿš€ Features

  • Keep GitHub Actions workflow files in sync across all your repositories
  • Sync any file or a whole directory to as many repositories as you want
  • Easy configuration for any use case
  • Create a pull request in the target repo so you have the last say on what gets merged
  • Automatically label pull requests to integrate with other actions like automerge-action
  • Assign users to the pull request
  • Render Jinja-style templates as use variables thanks to Nunjucks

๐Ÿ“š Usage

Workflow

Create a .yml file in your .github/workflows folder (you can find more info about the structure in the GitHub Docs):

.github/workflows/sync.yml

name: Sync Files
on:
  push:
    branches:
      - main
      - master
  workflow_dispatch:
jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@main
      - name: Run GitHub File Sync
        uses: BetaHuhn/repo-file-sync-action@v1
        with:
          GH_PAT: ${{ secrets.GH_PAT }}

Token

In order for the Action to access your repositories you have to specify a Personal Access token as the value for GH_PAT (GITHUB_TOKEN will not work). The PAT needs the full repo scope (#31).

It is recommended to set the token as a Repository Secret.

Alternatively, you can provide the token of a GitHub App Installation via the GH_INSTALLATION_TOKEN input. You can obtain such token for example via this action. Tokens from apps have the advantage that they provide more granular access control.

The app needs to be configured for each repo you want to sync to, and have the Contents read & write and Metadata read-only permission. If you want to use PRs (default setting) you additionally need Pull requests read & write access, and to sync workflow files you need Workflows read & write access.

If using an installation token you are required to provide the GIT_EMAIL and GIT_USERNAME input.

Sync configuration

The last step is to create a .yml file in the .github folder of your repository and specify what file(s) to sync to which repositories:

.github/sync.yml

user/repository:
  - .github/workflows/test.yml
  - .github/workflows/lint.yml

user/repository2:
  - source: workflows/stale.yml
    dest: .github/workflows/stale.yml

More info on how to specify what files to sync where below.

Versioning

To always use the latest version of the action add the latest tag to the action name like this:

uses: BetaHuhn/repo-file-sync-action@latest

If you want to make sure that your workflow doesn't suddenly break when a new major version is released, use the v1 tag instead (recommended usage):

uses: BetaHuhn/repo-file-sync-action@v1

With the v1 tag you will always get the latest non-breaking version which will include potential bug fixes in the future. If you use a specific version, make sure to regularly check if a new version is available, or enable Dependabot.

โš™๏ธ Action Inputs

Here are all the inputs repo-file-sync-action takes:

Key Value Required Default
GH_PAT Your Personal Access token GH_PAT or GH_INSTALLATION_TOKEN required N/A
GH_INSTALLATION_TOKEN Token from a GitHub App installation GH_PAT or GH_INSTALLATION_TOKEN required N/A
CONFIG_PATH Path to the sync configuration file No .github/sync.yml
IS_FINE_GRAINED Labels the GH_PAT as a fine grained token No false
PR_LABELS Labels which will be added to the pull request. Set to false to turn off No sync
ASSIGNEES Users to assign to the pull request No N/A
REVIEWERS Users to request a review of the pull request from No N/A
TEAM_REVIEWERS Teams to request a review of the pull request from No N/A
COMMIT_PREFIX Prefix for commit message and pull request title No ๐Ÿ”„
COMMIT_BODY Commit message body. Will be appended to commit message, separated by two line returns. No ''
PR_BODY Additional content to add in the PR description. No ''
ORIGINAL_MESSAGE Use original commit message instead. Only works if the file(s) were changed and the action was triggered by pushing a single commit. No false
COMMIT_AS_PR_TITLE Use first line of the commit message as PR title. Only works if ORIGINAL_MESSAGE is true and working. No false
COMMIT_EACH_FILE Commit each file seperately No true
GIT_EMAIL The e-mail address used to commit the synced files Only when using installation token the email of the PAT used
GIT_USERNAME The username used to commit the synced files Only when using installation token the username of the PAT used
OVERWRITE_EXISTING_PR Overwrite any existing Sync PR with the new changes No true
BRANCH_PREFIX Specify a different prefix for the new branch in the target repo No repo-sync/SOURCE_REPO_NAME
TMP_DIR The working directory where all git operations will be done No tmp-${ Date.now().toString() }
DRY_RUN Run everything except that nothing will be pushed No false
SKIP_CLEANUP Skips removing the temporary directory. Useful for debugging No false
SKIP_PR Skips creating a Pull Request and pushes directly to the default branch No false
FORK A Github account username. Changes will be pushed to a fork of target repos on this account. No false

Outputs

The action sets the pull_request_urls output to the URLs of any created Pull Requests. It will be an array of URLs to each PR, e.g. '["https://github.com/username/repository/pull/number", "..."]'.

๐Ÿ› ๏ธ Sync Configuration

In order to tell repo-file-sync-action what files to sync where, you have to create a sync.yml file in the .github directory of your main repository (see action-inputs on how to change the location).

The top-level key should be used to specify the target repository in the format username/repository-name@branch, after that you can list all the files you want to sync to that individual repository:

user/repo:
  - path/to/file.txt
user/repo2@develop:
  - path/to/file2.txt

There are multiple ways to specify which files to sync to each individual repository.

List individual file(s)

The easiest way to sync files is the list them on a new line for each repository:

user/repo:
  - .github/workflows/build.yml
  - LICENSE
  - .gitignore

Different destination path/filename(s)

Using the dest option you can specify a destination path in the target repo and/or change the filename for each source file:

user/repo:
  - source: workflows/build.yml
    dest: .github/workflows/build.yml
  - source: LICENSE.md
    dest: LICENSE

Sync entire directories

You can also specify entire directories to sync:

user/repo:
  - source: workflows/
    dest: .github/workflows/

Exclude certain files when syncing directories

Using the exclude key you can specify files you want to exclude when syncing entire directories (#26).

user/repo:
  - source: workflows/
    dest: .github/workflows/
    exclude: |
      node.yml
      lint.yml

Note: the exclude file path is relative to the source path

Don't replace existing file(s)

By default if a file already exists in the target repository, it will be replaced. You can change this behaviour by setting the replace option to false:

user/repo:
  - source: .github/workflows/lint.yml
    replace: false

Using templates

You can render templates before syncing by using the Jinja-style template syntax. It will be compiled using Nunjucks and the output written to the specific file(s) or folder(s).

Nunjucks supports variables and blocks among other things. To enable, set the template field to a context dictionary, or in case of no variables, true:

user/repo:
  - source: src/README.md
    template:
      user:
        name: 'Maxi'
        handle: '@BetaHuhn'

In the source file you can then use these variables like this:

# README.md

Created by {{ user.name }} ({{ user.handle }})

Result:

# README.md

Created by Maxi (@BetaHuhn)

You can also use extends with a relative path to inherit other templates. Take a look at Nunjucks template syntax for more info.

user/repo:
  - source: .github/workflows/child.yml
    template: true
# child.yml
{% extends './parent.yml' %}

{% block some_block %}
This is some content
{% endblock %}

Delete orphaned files

With the deleteOrphaned option you can choose to delete files in the target repository if they are deleted in the source repository. The option defaults to false and only works when syncing entire directories:

user/repo:
  - source: workflows/
    dest: .github/workflows/
    deleteOrphaned: true

It only takes effect on that specific directory.

Sync the same files to multiple repositories

Instead of repeating yourself listing the same files for multiple repositories, you can create a group:

group:
  repos: |
    user/repo
    user/repo1
  files: 
    - source: workflows/build.yml
      dest: .github/workflows/build.yml
    - source: LICENSE.md
      dest: LICENSE

You can create multiple groups like this:

group:
  # first group
  - files:
      - source: workflows/build.yml
        dest: .github/workflows/build.yml
      - source: LICENSE.md
        dest: LICENSE
    repos: |
      user/repo1
      user/repo2

  # second group
  - files: 
      - source: configs/dependabot.yml
        dest: .github/dependabot.yml
    repos: |
      user/repo3
      user/repo4

Syncing branches

You can also sync different branches from the same or different repositories (#51). For example, a repository named foo/bar with branch main, and sync.yml contents:

group:
  repos: |
    foo/bar@de
    foo/bar@es
    foo/bar@fr
  files:
    - source: .github/workflows/
      dest: .github/workflows/

Here all files in .github/workflows/ will be synced from the main branch to the branches de/es/fr.

๐Ÿ“– Examples

Here are a few examples to help you get started!

Basic Example

.github/sync.yml

user/repository:
  - LICENSE
  - .gitignore

Sync all workflow files

This example will keep all your .github/workflows files in sync across multiple repositories:

.github/sync.yml

group:
  repos: |
    user/repo1
    user/repo2
  files:
    - source: .github/workflows/
      dest: .github/workflows/

Custom labels

By default repo-file-sync-action will add the sync label to every PR it creates. You can turn this off by setting PR_LABELS to false, or specify your own labels:

.github/workflows/sync.yml

- name: Run GitHub File Sync
  uses: BetaHuhn/repo-file-sync-action@v1
  with:
    GH_PAT: ${{ secrets.GH_PAT }}
    PR_LABELS: |
      file-sync
      automerge

Assign a user to the PR

You can tell repo-file-sync-action to assign users to the PR with ASSIGNEES:

.github/workflows/sync.yml

- name: Run GitHub File Sync
  uses: BetaHuhn/repo-file-sync-action@v1
  with:
    GH_PAT: ${{ secrets.GH_PAT }}
    ASSIGNEES: BetaHuhn

Request a PR review

You can tell repo-file-sync-action to request a review of the PR from users with REVIEWERS and from teams with TEAM_REVIEWERS:

.github/workflows/sync.yml

- name: Run GitHub File Sync
  uses: BetaHuhn/repo-file-sync-action@v1
  with:
    GH_PAT: ${{ secrets.GH_PAT }}
    REVIEWERS: |
      BetaHuhn
      BetaHuhnBot
    TEAM_REVIEWERS: engineering

Custom GitHub Enterprise Host

If your target repository is hosted on a GitHub Enterprise Server you can specify a custom host name like this:

.github/workflows/sync.yml

https://custom.host/user/repo:
  - path/to/file.txt

# or in a group

group:
  - files:
      - source: path/to/file.txt
        dest: path/to/file.txt
    repos: |
      https://custom.host/user/repo

Note: The key has to start with http to indicate that you want to use a custom host.

Different branch prefix

By default all new branches created in the target repo will be in the this format: repo-sync/SOURCE_REPO_NAME/SOURCE_BRANCH_NAME, with the SOURCE_REPO_NAME being replaced with the name of the source repo and SOURCE_BRANCH_NAME with the name of the source branch.

If your repo name contains invalid characters, like a dot (#32), you can specify a different prefix for the branch (the text before /SOURCE_BRANCH_NAME):

.github/workflows/sync.yml

uses: BetaHuhn/repo-file-sync-action@v1
with:
    GH_PAT: ${{ secrets.GH_PAT }}
    BRANCH_PREFIX: custom-branch

The new branch will then be custom-branch/SOURCE_BRANCH_NAME.

You can use SOURCE_REPO_NAME in your custom branch prefix as well and it will be replaced with the actual repo name

Custom commit body

You can specify a custom commit body. This will be appended to the commit message, separated by two new lines. For example:

.github/workflows/sync.yml

- name: Run GitHub File Sync
  uses: BetaHuhn/repo-file-sync-action@v1
  with:
    GH_PAT: ${{ secrets.GH_PAT }}
    COMMIT_BODY: "Change-type: patch"

The above example would result in a commit message that looks something like this:

๐Ÿ”„ synced local '<filename>' with remote '<filename>'

Change-type: patch

Add content to the PR body

You can add more content to the PR body with the PR_BODY option. For example:

.github/workflows/sync.yml

- name: Run GitHub File Sync
  uses: BetaHuhn/repo-file-sync-action@v1
  with:
    GH_PAT: ${{ secrets.GH_PAT }}
    PR_BODY: This is your custom PR Body

It will be added below the first line of the body and above the list of changed files. The above example would result in a PR body that looks something like this:

synced local file(s) with GITHUB_REPOSITORY.

This is your custom PR Body

โ–ถ Changed files

---

This PR was created automatically by the repo-file-sync-action workflow run xxx.

Fork and pull request workflow

If you do not wish to grant this action write access to target repositories, you can specify a bot/user Github acccount that you do have access to with the FORK parameter.

A fork of each target repository will be created on this account, and all changes will be pushed to a branch on the fork, instead of upstream. Pull requests will be opened from the forks to target repositories.

Note: while you can open pull requests to target repositories without write access, some features, like applying labels, are not possible.

uses: BetaHuhn/repo-file-sync-action@v1
with:
    GH_PAT: ${{ secrets.GH_PAT }}
    FORK: file-sync-bot

Advanced sync config

Here's how I keep common files in sync across my repositories. The main repository github-files contains all the files I want to sync and the repo-file-sync-action Action which runs on every push.

Using groups I can specify which file(s) should be synced to which repositories:

.github/sync.yml

group:
  # dependabot files
  - files:
      - source: configs/dependabot.yml
        dest: .github/dependabot.yml
      - source: workflows/dependencies/dependabot.yml
        dest: .github/workflows/dependabot.yml
    repos: |
      BetaHuhn/do-spaces-action
      BetaHuhn/running-at
      BetaHuhn/spaces-cli
      BetaHuhn/metadata-scraper
      BetaHuhn/ejs-serve
      BetaHuhn/feedback-js
      BetaHuhn/drkmd.js

  # GitHub Sponsors config
  - files:
      - source: configs/FUNDING.yml
        dest: .github/FUNDING.yml
    repos: |
      BetaHuhn/do-spaces-action
      BetaHuhn/running-at
      BetaHuhn/spaces-cli
      BetaHuhn/qrgen
      BetaHuhn/metadata-scraper
      BetaHuhn/ejs-serve
      BetaHuhn/feedback-js
      BetaHuhn/drkmd.js

  # Semantic release
  - files:
      - source: workflows/versioning/release-scheduler.yml
        dest: .github/workflows/release-scheduler.yml
      - source: workflows/versioning/release.yml
        dest: .github/workflows/release.yml
      - source: configs/release.config.js
        dest: release.config.js
    repos: |
      BetaHuhn/do-spaces-action
      BetaHuhn/metadata-scraper
      BetaHuhn/feedback-js
      BetaHuhn/drkmd.js

  # Stale issues workflow
  - files:
      - source: workflows/issues/stale.yml
        dest: .github/workflows/stale.yml
    repos: |
      BetaHuhn/do-spaces-action
      BetaHuhn/running-at
      BetaHuhn/spaces-cli
      BetaHuhn/qrgen
      BetaHuhn/metadata-scraper
      BetaHuhn/ejs-serve
      BetaHuhn/feedback-js
      BetaHuhn/drkmd.js

  # Lint CI workflow
  - files:
      - source: workflows/node/lint.yml
        dest: .github/workflows/lint.yml
    repos: |
      BetaHuhn/do-spaces-action
      BetaHuhn/running-at
      BetaHuhn/spaces-cli
      BetaHuhn/metadata-scraper
      BetaHuhn/ejs-serve
      BetaHuhn/feedback-js
      BetaHuhn/drkmd.js

  # MIT License
  - files:
      - source: LICENSE
        dest: LICENSE
    repos: |
      BetaHuhn/do-spaces-action
      BetaHuhn/running-at
      BetaHuhn/spaces-cli
      BetaHuhn/qrgen
      BetaHuhn/metadata-scraper
      BetaHuhn/ejs-serve
      BetaHuhn/feedback-js
      BetaHuhn/drkmd.js

๐Ÿ’ป Development

Issues and PRs are very welcome!

The actual source code of this library is in the src folder.

  • run yarn lint or npm run lint to run eslint.
  • run yarn start or npm run start to run the Action locally.
  • run yarn build or npm run build to produce a production version of repo-file-sync-action in the dist folder.

โ” About

This project was developed by me (@betahuhn) in my free time. If you want to support me:

Donate via PayPal

ko-fi

Credits

This Action was inspired by:

๐Ÿ“„ License

Copyright 2021 Maximilian Schiller

This project is licensed under the MIT License - see the LICENSE file for details.

repo-file-sync-action's People

Contributors

adaam avatar aidanfogarty avatar alvarezfr avatar arjunreddyk avatar balazsorban44 avatar barrydobson avatar betahuhn avatar betahuhnbot avatar bytestream avatar dependabot[bot] avatar dhruvkb avatar erezrokah avatar exaspark avatar grahammcculloch avatar jpoehnelt avatar kkoutsilis avatar leocete avatar maikenp avatar nef10 avatar phnx47 avatar rasa avatar samagius avatar sammcj avatar sorekz avatar svg153 avatar thomasleclaire avatar xanjohns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

repo-file-sync-action's Issues

Error: Cannot create a new GitHub Tree: Server Error

๐Ÿž Describe the bug

Hello when I am trying to use the action with a GitHub App, I am having this error. Any help is appreciated.

๐Ÿ“š To reproduce

๐Ÿ’ก Expected behavior

A PR against the specified branch to be created.

๐Ÿ–ผ๏ธ Screenshots

image

image

โš™๏ธ Environment

@v1

๐Ÿ“‹ Additional context

No response

Rate limit exceeded during pull-request

๐Ÿž Describe the bug

Appears that when attempting to sync many repos github may throttle the number of pull-requests that can be made and will result in only partially completing the full list.

...
Locally syncing file(s) between source and target repository
Source is directory
Pushing changes to target repository
Creating new PR
Error: You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.
Error: HttpError: You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.
Repository Info
Slug		: client-config
Owner		: acme-corp
Https Url	: https://github.com/acme-corp/client-config
Branch		: master
	
Locally syncing file(s) between source and target repository
Source is directory
Pushing changes to target repository
Creating new PR
Error: You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.
Error: HttpError: You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.
Repository Info
Slug		: app-config
Owner		: acme-corp
Https Url	: https://github.com/acme-corp/app-config
Branch		: master
	
Locally syncing file(s) between source and target repository
Source is directory
Pushing changes to target repository
Creating new PR
Error: You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.
Error: HttpError: You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.
Repository Info
Slug		: api-config
Owner		: acme-corp
Https Url	: https://github.com/acme-corp/api-config
Branch		: master
...
...

๐Ÿ“š To Reproduce

Perform many syncs within one of the limits. Could be x per hour or x per minute.

๐Ÿ’ก Expected behavior

Either fast-fail and exit non-zero or retry after 5-10 seconds as per some (additional) action input. The action shouldn't indicate that it was successful if it didn't actually perform all the updates in the config (sync.yml).

๐Ÿ–ผ๏ธ Screenshots

image

notice the matrix shows 12 jobs, but my sync.yml has 20 repos listed.

image

โš™๏ธ Environment

๐Ÿ“‹ Additional context

Add any other context about the problem here.

sporadic "Server Error" on adding labels

๐Ÿž Describe the bug

We have sporadic "Server Error" messages (and therefore failed pipelines) when the action is trying to set labels.
The label does exist in the downstream repo.
It's also not a permission issue, as we tried different levels of access tokens, all with the same result.

We are syncing a fairly large sync list (currently ~100 repositories)

Personal hunch: Could it be that we are hitting GitHub API rate limiting?

๐Ÿ“š To reproduce

- name: Run GitHub File Sync
  uses: BetaHuhn/[email protected]
  with:
    GH_PAT: ${{ secrets.PAT }}
    COMMIT_EACH_FILE: false
    PR_LABELS: |
      sync
    COMMIT_PREFIX: "sync: "
    ORIGINAL_MESSAGE: true
  • run this like 100 times with a change set, so a PR will be created/updated
  • (doesn't matter a if a downstream PR already exists or not)
  • (we tested it so far only with private repositories)

๐Ÿ’ก Expected behavior

No "Server Error" or at least a more meaningful debug message

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

  • ubuntu-latest runner
  • latest release of the action (1.21.0 by the time of writing)

๐Ÿ“‹ Additional context

log output

Repository Info
Slug		: my-private-repo
Owner		: my-org
Https Url	: https://github.com/my-org/my-private-repo
Branch		: main
	
Found existing PR 392
Locally syncing file(s) between source and target repository
Source is directory
Pushing changes to target repository
Overwriting existing PR
Notice: Pull Request #392 created/updated: https://github.com/my-org/my-private-repo/pull/392
Adding label(s) "sync" to PR
Error: Server Error

Actions fail in v1.17.18

๐Ÿž Describe the bug

After this merge, our workflows failed.
Look at the screenshots.

๐Ÿ“š To Reproduce

  • Having a working configuration
  • Update the action version to v1.17.18
  • Run the sync workflow

๐Ÿ’ก Expected behavior

Works like version v1.17.17

๐Ÿ–ผ๏ธ Screenshots

Action trace screenshot

failed

As seen in the commit screenshot.

commit

  • We made a change in PR-110. We added the variable BRANCH_PREFIX: 'admin/sync/actions' for the Sync common GitHub Actions workflow, but as you can see, all of them failed, not just the modified workflow.
  • We made a PR-111 to put the version v1.17.17 and everything worked fine.

โš™๏ธ Environment

๐Ÿ“‹ Additional context

  • After the rollback to version v1.17.17 everything worked fine.
  • cc: @gomete

Error when syncing suddenly

๐Ÿž Describe the bug

When the auto-sync runs I'm now getting an error

<html>
<body>
<!--StartFragment-->
syncCommand failed: git rev-parse --abbrev-ref HEAD fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'
--


<!--EndFragment-->
</body>
</html>[sync](https://github.com/Bearsampp/.settings/actions/runs/9405986866/job/25908384401#step:3:257)
Command failed: git rev-parse --abbrev-ref HEAD fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'

๐Ÿ“š To reproduce

Run sync action

๐Ÿ’ก Expected behavior

syncs properly

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

https://github.com/Bearsampp/.settings/blob/main/.github/sync.yml
https://github.com/Bearsampp/.settings/blob/main/.github/workflows/sync.yml
https://github.com/Bearsampp/.settings/actions/runs/9405986866

๐Ÿ“‹ Additional context

No response

GitHub rate limit triggered when syncing a lot of repositories

๐Ÿž Describe the bug

When executing the repo-file-sync-action in my workflow, it shows as successfully having completed but the logs show multiple instances of the following error:

Error: You have triggered an abuse detection mechanism and have been temporarily blocked from content creation. Please retry your request again later.

Each time this error is reported, the PR fails to be created. For example:

Repository Info
Slug		: jellyfish-queue
Owner		: product-os
Https Url	: https://github.com/product-os/jellyfish-queue
Branch		: default
	
Locally syncing file(s) between source and target repository
Pushing changes to target repository
Creating new PR
Error: You have triggered an abuse detection mechanism and have been temporarily blocked from content creation. Please retry your request again later.
Error: HttpError: You have triggered an abuse detection mechanism and have been temporarily blocked from content creation. Please retry your request again later.

No PR is created on the jellyfish-queue repo.

๐Ÿ“š To Reproduce

Create a sync.yml file that should result in PRs being created on a lot (about 20) of repos.

๐Ÿ’ก Expected behavior

No errors logged, all expected PRs successfully created.

๐Ÿ–ผ๏ธ Screenshots

N/A

โš™๏ธ Environment

  • Action version: 1.7.0

๐Ÿ“‹ Additional context

I'm not sure if this means the GitHub user associated with GH_PAT has been rate-limited or whether repo-file-sync-action or the workflow itself has been rate-limited?

Either way, I wonder if it would help to add a RATE_LIMIT option or similar that could be used to throttle the action's requests to the GitHub API to mitigate this error?

Deletion of a file does not trigger the sync action.

๐Ÿž Describe the bug

Deletion of a file does not trigger the sync action.

๐Ÿ“š To Reproduce

  1. Configure repo sync action on a particular directory
  2. Add some files there.
  3. Delete one of the files.

๐Ÿ’ก Expected behavior

A new PR opened with file deletion.

๐Ÿ–ผ๏ธ Screenshots

If applicable, add screenshots to help explain your problem.

โš™๏ธ Environment

  • Action version: [e.g. v1.0.0]

๐Ÿ“‹ Additional context

Add any other context about the problem here.

Newest version does not run after ESM change

๐Ÿž Describe the bug

2023-01-07T17:44:55.0909616Z ##[endgroup]
2023-01-07T17:44:55.1588432Z undefined:1
2023-01-07T17:44:55.1589393Z require
2023-01-07T17:44:55.1589809Z ^
2023-01-07T17:44:55.1590021Z 
2023-01-07T17:44:55.1590612Z ReferenceError: require is not defined in ES module scope, you can use import instead
2023-01-07T17:44:55.1592294Z This file is being treated as an ES module because it has a '.js' file extension and '/home/runner/work/_actions/BetaHuhn/repo-file-sync-action/v1/dist/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
2023-01-07T17:44:55.1593995Z     at eval (eval at 539 (file:///home/runner/work/_actions/BetaHuhn/repo-file-sync-action/v1/dist/index.js:1:41342), <anonymous>:1:1)
2023-01-07T17:44:55.1594984Z     at Object.539 (file:///home/runner/work/_actions/BetaHuhn/repo-file-sync-action/v1/dist/index.js:1:41342)
2023-01-07T17:44:55.1595948Z     at __nccwpck_require__ (file:///home/runner/work/_actions/BetaHuhn/repo-file-sync-action/v1/dist/index.js:1:42491)
2023-01-07T17:44:55.1596987Z     at file:///home/runner/work/_actions/BetaHuhn/repo-file-sync-action/v1/dist/index.js:1:42877
2023-01-07T17:44:55.1597862Z     at file:///home/runner/work/_actions/BetaHuhn/repo-file-sync-action/v1/dist/index.js:1:47000
2023-01-07T17:44:55.1598624Z     at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
2023-01-07T17:44:55.1599193Z     at async Promise.all (index 0)
2023-01-07T17:44:55.1599766Z     at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
2023-01-07T17:44:55.1600397Z     at async loadESM (node:internal/process/esm_loader:88:5)
2023-01-07T17:44:55.1601027Z     at async handleMainPromise (node:internal/modules/run_main:65:12)

๐Ÿ“š To reproduce

Just try to run it

๐Ÿ’ก Expected behavior

It syncs

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

Version 69868d68f6969b7a599ca783823eb29e3b3679e8

๐Ÿ“‹ Additional context

See https://github.com/Nef10/common-swift-package/actions/runs/3863217212/jobs/6585266148

Action showing error

๐Ÿž Describe the bug

The actions shows errors: core.notice is not a function and syncTypeError: core.notice is not a function, assignee and labels are not set. See here.

๐Ÿ“š To Reproduce

Run the action with a file to sync.

๐Ÿ’ก Expected behavior

No error, assignee are labels set as configured.

๐Ÿ–ผ๏ธ Screenshots

Screen Shot 2021-09-06 at 5 14 39 PM

โš™๏ธ Environment

Latest

๐Ÿ“‹ Additional context

The problem was caused because the built after merging #101 was not done correctly (it used outdated dependencies). As I noted in the PR:

When working on this I noticed that the current version does not seem to be built correctly. When I check out develop and run a build there is a diff to the checked in dist file. This change seems to be the bump of @actions/core to 1.5.0. This version is required for this change, so please make sure to update the dependencies to the version of the lock file before building.

sync a folder with deleteOrphaned fail to really delete files

๐Ÿž Describe the bug

I have a folder synchronized from the origin repo to the destination one with the deleteOrphaned setting enabled.
If some files are added in this folder in the destination repo (or already exist before first sync) they are not deleted.
In the same idea, if we delete the folder from the origin repo, we have no way to delete folder in the destination repo.

got these errors in logs :

Error: Cannot read property 'includes' of undefined
Error: TypeError: Cannot read property 'includes' of undefined

๐Ÿ’ก Expected behavior

Some way to really sync folder between repos. ie delete all existing files if not in the root folder, and some way to delete a folder.

โš™๏ธ Environment

  • Action version: v1

Exclude should not remove excluded files if deleteOrphaned is true

๐Ÿž Describe the bug

Files which are excluded are still being deleted if deleteOrphaned is true.

This seems to be an edge case when using deleteOrphaned and excluded. However I still think it is a bug, at least not the behaviour I am expecting.

๐Ÿ“š To Reproduce

  1. Create a sync for a folder
  2. Set deleteOrphaned to true
  3. Exclude a specific file in this folder, which is not present
  4. Sync to a repo where this file is present

๐Ÿ’ก Expected behavior

The file should not be deleted.

๐Ÿ–ผ๏ธ Screenshots

Screen Shot 2021-09-04 at 9 01 30 PM

Screen Shot 2021-09-04 at 9 01 10 PM

โš™๏ธ Environment

@v1 (using 1.12.0)

Command failed: git ls-tree -r --full-tree

๐Ÿž Describe the bug

The actions fails with Error: Command failed: git ls-tree -r --full-tree

๐Ÿ“š To Reproduce

Please see my config here:

๐Ÿ’ก Expected behavior

Should sync correctly.

๐Ÿ“„ Logs

The run is here: https://github.com/Nef10/swiftlint-config/runs/6332482552?check_suite_focus=true

Debug Log
2022-05-07T05:34:10.0592535Z ##[debug]Loading env
2022-05-07T05:34:10.0599012Z ##[group]Run BetaHuhn/repo-file-sync-action@v1
2022-05-07T05:34:10.0599458Z with:
2022-05-07T05:34:10.0600044Z   GH_INSTALLATION_TOKEN: ***
2022-05-07T05:34:10.0600547Z   GIT_EMAIL: 89714990+file-sync-app[bot]@users.noreply.github.com
2022-05-07T05:34:10.0601085Z   GIT_USERNAME: file-sync-app[bot]
2022-05-07T05:34:10.0601517Z   ORIGINAL_MESSAGE: true
2022-05-07T05:34:10.0601931Z   COMMIT_EACH_FILE: false
2022-05-07T05:34:10.0602326Z   SKIP_PR: true
2022-05-07T05:34:10.0602709Z ##[endgroup]
2022-05-07T05:34:10.2341759Z ::add-mask::***
2022-05-07T05:34:10.2347320Z ##[debug]{
2022-05-07T05:34:10.2348036Z ##[debug]  "GITHUB_TOKEN": "***",
2022-05-07T05:34:10.2348680Z ##[debug]  "IS_INSTALLATION_TOKEN": true,
2022-05-07T05:34:10.2349236Z ##[debug]  "GIT_EMAIL": "89714990+file-sync-app[bot]@users.noreply.github.com",
2022-05-07T05:34:10.2349812Z ##[debug]  "GIT_USERNAME": "file-sync-app[bot]",
2022-05-07T05:34:10.2350290Z ##[debug]  "CONFIG_PATH": ".github/sync.yml",
2022-05-07T05:34:10.2350721Z ##[debug]  "COMMIT_BODY": "",
2022-05-07T05:34:10.2351162Z ##[debug]  "COMMIT_PREFIX": "๐Ÿ”„",
2022-05-07T05:34:10.2351583Z ##[debug]  "COMMIT_EACH_FILE": false,
2022-05-07T05:34:10.2352005Z ##[debug]  "PR_LABELS": [
2022-05-07T05:34:10.2352387Z ##[debug]    "sync"
2022-05-07T05:34:10.2352744Z ##[debug]  ],
2022-05-07T05:34:10.2353107Z ##[debug]  "PR_BODY": "",
2022-05-07T05:34:10.2353517Z ##[debug]  "TMP_DIR": "tmp-1651901650229",
2022-05-07T05:34:10.2353941Z ##[debug]  "DRY_RUN": false,
2022-05-07T05:34:10.2354339Z ##[debug]  "SKIP_CLEANUP": false,
2022-05-07T05:34:10.2354763Z ##[debug]  "OVERWRITE_EXISTING_PR": true,
2022-05-07T05:34:10.2355255Z ##[debug]  "GITHUB_REPOSITORY": "Nef10/swiftlint-config",
2022-05-07T05:34:10.2355717Z ##[debug]  "SKIP_PR": true,
2022-05-07T05:34:10.2356115Z ##[debug]  "ORIGINAL_MESSAGE": true,
2022-05-07T05:34:10.2356849Z ##[debug]  "COMMIT_AS_PR_TITLE": false,
2022-05-07T05:34:10.2357326Z ##[debug]  "BRANCH_PREFIX": "repo-sync/SOURCE_REPO_NAME",
2022-05-07T05:34:10.2357785Z ##[debug]  "FORK": false
2022-05-07T05:34:10.2358343Z ##[debug]}
2022-05-07T05:34:10.2466685Z Repository Info
2022-05-07T05:34:10.2491513Z Slug		: common-swift-package
2022-05-07T05:34:10.2492197Z Owner		: Nef10
2022-05-07T05:34:10.2493240Z Https Url	: https://github.com/Nef10/common-swift-package
2022-05-07T05:34:10.2494526Z Branch		: default
2022-05-07T05:34:10.2494887Z 	
2022-05-07T05:34:10.2495904Z ##[debug]Cloning github.com/Nef10/common-swift-package into tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.2497824Z ##[debug]EXEC: "git clone --depth 1  ***github.com/Nef10/common-swift-package.git tmp-1651901650229/github.com/Nef10/common-swift-package@default" IN undefined
2022-05-07T05:34:10.4376154Z ##[debug]Setting git user to email: 89714990+file-sync-app[bot]@users.noreply.github.com, username: file-sync-app[bot]
2022-05-07T05:34:10.4377739Z ##[debug]EXEC: "git config --local user.name "file-sync-app[bot]" && git config --local user.email "89714990+file-sync-app[bot]@users.noreply.github.com"" IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.4452994Z ##[debug]EXEC: "git rev-parse --abbrev-ref HEAD" IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.4509802Z ##[debug]EXEC: "git rev-parse HEAD" IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.4537622Z Locally syncing file(s) between source and target repository
2022-05-07T05:34:10.4549900Z ##[debug]CP: .swiftlint.yml TO tmp-1651901650229/github.com/Nef10/common-swift-package@default/.swiftlint.yml
2022-05-07T05:34:10.4573152Z ##[debug]EXEC: "git add -f ".swiftlint.yml"" IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.4617424Z ##[debug]EXEC: "git status --porcelain" IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.4664237Z ##[debug]Creating commit for remaining files
2022-05-07T05:34:10.7047389Z ##[debug]EXEC: "git diff HEAD .swiftlint.yml" IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.7110507Z ##[debug]EXEC: "git commit -m 'Update SwiftLint rules for 0.47.1'" IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.7189949Z Pushing changes to target repository
2022-05-07T05:34:10.7191456Z ##[debug]EXEC: "git log --format=%H --reverse main..HEAD" IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.7244940Z ##[debug]EXEC: "git log -1 --format=%B " IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.7268692Z ##[debug]EXEC: "git ls-tree -r --full-tree " IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.7283222Z ##[debug]Creating missing blobs on GitHub
2022-05-07T05:34:10.7284569Z ##[debug]EXEC: "git ls-tree -r --full-tree ~1" IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.7307442Z ##[debug]EXEC: "git ls-tree -r --full-tree " IN tmp-1651901650229/github.com/Nef10/common-swift-package@default
2022-05-07T05:34:10.7353249Z ##[error]Command failed: git ls-tree -r --full-tree 
usage: git ls-tree [<options>] <tree-ish> [<path>...]

    -d                    only show trees
    -r                    recurse into subtrees
    -t                    show trees when recursing
    -z                    terminate entries with NUL byte
    -l, --long            include object size
    --name-only           list only filenames
    --name-status         list only filenames
    --object-only         list only objects
    --full-name           use full path names
    --full-tree           list entire tree; not just current directory (implies --full-name)
    --format <format>     format to use for the output
    --abbrev[=<n>]        use <n> digits to display object names


2022-05-07T05:34:10.7363115Z ##[debug]{"killed":false,"code":129,"signal":null,"cmd":"git ls-tree -r --full-tree "}

๐Ÿ“‹ Additional context

Last ran synced correctly with the same config on Jan 22.

Fails to sync

Having a problem where its not wanting to sync.

๐Ÿž Describe the bug

Action will not process

๐Ÿ“š To Reproduce
run my file-sync.yml action

๐Ÿ’ก Expected behavior

completes assigned tasks

๐Ÿ–ผ๏ธ Screenshots

[](http:// .github/workflows/file-sync.yml

GitHub Actions: Transitioning from Node 16 to Node 20

๐Ÿž Describe the bug

Node 16 has reached its end of life, prompting us to initiate its deprecation process for GitHub Actions. Our plan is to transition all actions to run on Node 20 by Spring 2024. We will actively monitor the migration's progress and gather community feedback before finalizing the transition date. Starting October 23rd, workflows containing actions running on Node 16 will display a warning to alert users about the upcoming migration.

https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/

๐Ÿ“š To reproduce

Use the action

๐Ÿ’ก Expected behavior

No deprecation warning

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

1.21.0

๐Ÿ“‹ Additional context

No response

Weird behavior when syncing two directories

๐Ÿž Describe the bug

I noticed a weird behavior when trying to sync two directories like this:

user/repo:
  - source: .github/ISSUE_TEMPLATE/
    dest: issues/

If issues/ already exists, the files from .github/ISSUE_TEMPLATE/ end up in issues/ISSUE_TEMPLATE/ instead of in issues/ as you would expect.

After investigating I found that the package used to copy files in this action, @actions/io, creates a new folder from the basename of the source path and copys the source files into it when the target directory already exists.

Here are the lines responsible for this behavior:

  // If dest is an existing directory, should copy inside.
  const newDest: string =
    destStat && destStat.isDirectory()
      ? path.join(dest, path.basename(source))
      : dest

From: https://github.com/actions/toolkit/blob/4dd900dde00dcc90e5c649b688c643b1fc7684a2/packages/io/src/io.ts#L47-L51

๐Ÿ“‹ Additional context

I filed an issue (#741) in GitHub's Actions Toolkit repo and will wait a bit for their response. If this doesn't get addressed in a reasonable amount of time I will use another library, or the shell directly, to copy files/directories in this action.

Please let me know if you run into this problem as well or if you have another idea for a solution. Thanks!

Action not marked as failed if an error occurs

๐Ÿž Describe the bug

The actions run is marked as success even though an error occurred.

๐Ÿ“š To Reproduce

Use an invalid token, or a token which does not have correct access.

๐Ÿ’ก Expected behavior

The workflow run should be marked as failed.

๐Ÿ–ผ๏ธ Screenshots

See
https://github.com/Nef10/swift-package-common/actions/runs/1178374879
https://github.com/Nef10/swift-package-common/actions/runs/1178388705

โš™๏ธ Environment

BetaHuhn/repo-file-sync-action@v1

Missing Documentation for PR_BODY property

๐Ÿž Describe the bug

The README.md does not have documentation for the PR_BODY property how it works and what the default is.

Would also be nice to have an example for folks to follow.

Allow configuring parameters for Nunjucks

๐Ÿž Describe the bug

Currently some configuration options for Nunjucks are hardcoded into the action.

nunjucks.configure({ autoescape: true, trimBlocks: true, lstripBlocks: true })

These can be incompatible with the needs of a project. For example, in a YAML project, autoescape can cause single quotes (') to be replaced with HTML entity codes (&#39;).

๐Ÿ“š To reproduce

Use a template-based approach to write YAML containing single quotes.

๐Ÿ’ก Expected behavior

Nunjucks should be configurable by setting some options on the action that are passed into the nunjucks.configure function.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

v1.18.0

๐Ÿ“‹ Additional context

I'd be happy to open a PR to resolve this.

Action is pulling in binary files in a repo

๐Ÿž Describe the bug
Syncing a file in a repo that has binary files will include those binary files in the PR and also modifies them.

Bug is recreated in this repo:

https://github.com/cds-snc/sre-test-repo

Here is the PR:
cds-snc/sre-test-repo#2

Please note this PR was triggered by another repo just to prove that it does occur in normal usage instead of just in the repo it was run in as I originally reported.

๐Ÿ“š To Reproduce

  • authenticate using a Token from a GitHub App installation

  • Add a binary file to a repo.

To create a basic binary file run the following command in bash

echo "00000000: ff" | xxd -r - binary.dat
  • Run the action and the binary file will be apart of the PR even if it is not part of the configuration.

๐Ÿ’ก Expected behavior

I expect only the files identified to show up in the repo.

๐Ÿ–ผ๏ธ Screenshots

Screen shot of files in PR in case it dissapears.

image

โš™๏ธ Environment
We pin Git SHA

๐Ÿ“‹ Additional context

It converted a basic binary file from in hex, so I imagine there might be an issue with binary files and this action.

FF 0F to EF BF BD 0F

I also ran into an issue with a larger binary file, when using an image of about 960kb ran into the following error:
stdout maxBuffer length exceeded

Some test runs:

Keep creating empty PRs after each push

๐Ÿž Describe the bug

Hello,

I really loved the idea and integrated my project into repo-file-sync-action. Just realized that I am having empty PRs with 2 comits but no change. For example, the PR here: SubMob/LogMob#115

How to avoid creating PRs if nothing changed ?

I thought if I merge one of the empty PR then it will no longer create (since the 2 commits would be merged) but no luck, I actually merged one of these PRs, but new ones are keep coming. For example in the same repo I had this PR: SubMob/LogMob#113 and merged it, but it didn't fix the situation.

๐Ÿ“š To reproduce

Not sure how you can reproduce this, but I put an example of the PRs, maybe you can see the logs, and I am willing to do anything you might think helpful

๐Ÿ’ก Expected behavior

If there is no diff, no PR should be created.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

1.21.0, latest

๐Ÿ“‹ Additional context

No response

Problem setting git username/email with GH_PAT only

๐Ÿž Describe the bug

Our sync action stopped working ~5 days ago (seemingly after this was merged - #153). Throwing an error that the git username/email was missing.

We're passing only a GH_PAT, not an installation token.

๐Ÿ–ผ๏ธ Screenshots

image

See last working run: https://github.com/nextauthjs/next-auth/actions/runs/1809749953
Failing run: https://github.com/nextauthjs/next-auth/actions/runs/1815281481

๐Ÿ“‹ Additional context

Sync action: https://github.com/nextauthjs/next-auth/blob/main/.github/workflows/sync-example.yml
Sync config: https://github.com/nextauthjs/next-auth/blob/main/.github/sync.yml

Replace & deleteOrphaned always have the value of default

๐Ÿž Describe the bug

When setting a file to replace: false the setting is always true

๐Ÿ“š To Reproduce

Add a sync config that has the replace field set to false for a file

๐Ÿ’ก Expected behavior

Expect file to not be replaced

โš™๏ธ Environment

  • Action version: latest

Template rendering doesn't work alongside `dest`

๐Ÿž Describe the bug

It seems as though when you want to use the Jinja templating, you cannot specify the dest keyword in the config alongside template

๐Ÿ“š To reproduce

Set the sync.yml file to:

project/repo_1:
  - source: folder/file.py
    dest: file.py
    template:
      name: dale

Then the file.py file will incorrectly be rendered as:

name = {{ name }}

๐Ÿ’ก Expected behavior

I'd like to set the sync.yml file as:

project/repo_1:
  - source: folder/file.py
    dest: another_folder/file.py
    template:
      name: dale

Which will be rendered as:

name = dale

This file will live in another_folder/file.py in the destination repo. Currently, if you remove dest from the config, then it will render the output correctly, however it will sync it to the wrong path in the destination repo.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

v1

๐Ÿ“‹ Additional context

This does work for a non-python example:

project/repo_1:
  - source: folder/file.yml
    dest: another_folder/file.yml
    template:
      name: dale

Invalid PR branch when used in repos with a leading dot

๐Ÿž Describe the bug

When trying to use the action from a repo whose name starts with a dot like .github (community health files), it fails with git errors when it tries to create the PR branch:

Error: Error: Command failed: git checkout -b "repo-sync/.github/default"
fatal: 'repo-sync/.github/default' is not a valid branch name.

๐Ÿ“š To Reproduce

Use the action in a repo whose name wouldn't be a valid Git branch.

๐Ÿ’ก Expected behavior

Invalid characters in names should be filtered out.

๐Ÿ–ผ๏ธ Screenshots

If applicable, add screenshots to help explain your problem.

โš™๏ธ Environment

  • Action version: v.1.5.0

๐Ÿ“‹ Additional context

Alternatively it would be great to be able to specify the name of the branch, or the branch suffix.

Exclude overlap causing missed files in sync

๐Ÿž Describe the bug

Using exclude in the sync config appears to break further overlapping sync group configs.

๐Ÿ“š To reproduce

Here's an abbreviated example:

groups:
  - files:
      - folder/
        exclude: b.txt
    repos: |
      org/repo@master

  - files:
      - folder/b.txt
    repos: |
      org/repo@master

In this example, b.txt is never synced. In our use-case, we were looking to sync a mostly standard template that was structured appropriately, but include unique Dockerfiles from a different folder.

๐Ÿ’ก Expected behavior

I'd expect both files a.txt and b.txt to be synced to the repo.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

v1.21.0

๐Ÿ“‹ Additional context

No response

Missing escaping

๐Ÿž Describe the bug

E.g. when using `id` in the commit message the string is not correctly escaped and thus being replaced. See this commit which synced to this with the ORIGINAL_MESSAGE flag on.

๐Ÿ“š To Reproduce

Include `something` in a commit message and sync with the ORIGINAL_MESSAGE flag.

๐Ÿ’ก Expected behavior

The string should not be changed.

๐Ÿ–ผ๏ธ Screenshots

See links above.

โš™๏ธ Environment

Latest v1.

deleteOrphaned seems to have no effect

๐Ÿž Describe the bug

Despite the inclusion of deleteOrphaned: true in .github/sync.yml, files deleted in the source repo don't get deleted from the destination repo. In addition, folders renamed in the source repo appear twice in the destination repo, with old and new names.

๐Ÿ“š To reproduce

In source repo

# .github/sync.yml
zoylendt/zoylendt.github.io@v4:
  - source: public/
    dest: content/
    deleteOrphaned: true
# .github/workflows/sync.yml
name: Sync Files
on:
  push:
    branches:
      - main
  workflow_dispatch:
jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@master
      - name: Run GitHub File Sync
        uses: BetaHuhn/repo-file-sync-action@latest
        with:
          GH_PAT: ${{ secrets.GH_PAT }}
          SKIP_PR: true

Folder structure:

 /
 โ”œโ”€โ”€ .github
 โ”‚   โ”œโ”€โ”€ sync.yml
 โ”‚   โ””โ”€โ”€ workflows
 โ”‚       โ””โ”€โ”€ sync.yml
 โ”œโ”€โ”€ private
 โ”‚   โ””โ”€โ”€ .gitkeep
 โ””โ”€โ”€ public
     โ”œโ”€โ”€ A.md
     โ””โ”€โ”€ folder2
         โ””โ”€โ”€ C.md

In destination repo

B.md has been deleted in the source repo, folder1 has been renamed to folder2 (both after they have been synced to the destination repo). However, they don't get deleted from the destination repo.

Folder structure:

 /
 โ”œโ”€โ”€ .github
 โ”œโ”€โ”€ misc
 โ”‚   โ””โ”€โ”€ .gitkeep
 โ””โ”€โ”€ content
     โ”œโ”€โ”€ A.md
     โ”œโ”€โ”€ B.md
     โ””โ”€โ”€ folder1
     โ”‚   โ””โ”€โ”€ C.md
     โ””โ”€โ”€ folder2
         โ””โ”€โ”€ C.md

๐Ÿ’ก Expected behavior

Deleted/renamed files in the source repo and folders should be deleted/renamed in the destination repo aswell, including files/folders in subdirectories.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

Tested with v1 and latest, as mentioned here: https://github.com/BetaHuhn/repo-file-sync-action?tab=readme-ov-file#versioning

๐Ÿ“‹ Additional context

No error messages appear in the actions log.
I authenticated using GH_PAT, with full repo scope, see #31
Maybe the issue is related to SKIP_PR: true?

Cannot set commit message as the title of the PR

๐Ÿž Describe the bug

I am triggering the action by pushing only 1 commit to test branch. But the PR title remains the default one:
Synced file(s) with user/repo name.

My workflow file:

    on:
      push:
        branches:
          - test
      workflow_dispatch:
    jobs:
      sync:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout Repository
            uses: actions/checkout@v2
    
          - name: Generate token
            id: generate_token
            uses: tibdex/github-app-token@v1
            with:
              app_id: xxxxxx
              private_key: ${{ secrets.PRIVATE_KEY }}
    
          - name: Run GitHub File Sync
            uses: BetaHuhn/[email protected]
            with:
              GH_INSTALLATION_TOKEN: ${{ steps.generate_token.outputs.token }}
              ORIGINAL_MESSAGE: true
              COMMIT_AS_PR_TITLE: true
              GIT_EMAIL: [email protected]
              GIT_USERNAME: test

๐Ÿ“š To reproduce

Create a test repo source and dest, use the action and above configuration.

๐Ÿ’ก Expected behavior

Created PR having my commit message as its title.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

v1.21.17
tested also in previous versions

๐Ÿ“‹ Additional context

No response

Syncing through forked repo hits "shallow update not allowed" after the first pull request is merged into target repo

๐Ÿž Describe the bug

I synced with FORK parameter referring to Fork and pull request workflow.
The action could successfully create the first pull request targeting to the target repo through forked repo. Once the first pull request is merged, when I push some change to the sync file next time in source repo the action run failed due to shallow update not allowed error, like https://github.com/GangWang01/Experiment/actions/runs/3443890910.
The error is a result of main branch of forked repo is some commits behind target repo. To work around this problem, I have to manually sync forked repo from its upstream(the target repo). However it doesn't make sense for the purpose of this action.

BTW, ORIGINAL_MESSAGE and COMMIT_AS_PR_TITLE don't work when syncing file through forked repo.

๐Ÿ“š To reproduce

  1. https://github.com/GangWang01/Experiment is the source repo and it's configured to use this action with FORK parameter. This is my own repo I have write access.
  2. https://github.com/JaynieBai/ManageTestResults is the target repo. I don't have write access to it.
  3. Merge the first pull request created by the action.
  4. Push some change to the file that needs to sync to source repo. Then check if the run fails with the error.

๐Ÿ’ก Expected behavior

It's very helpful syncing through forked repo could work well.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

Neither BetaHuhn/repo-file-sync-action@v1 nor BetaHuhn/repo-file-sync-action@latest works.

๐Ÿ“‹ Additional context

No response

Security Contact - missing

๐Ÿž Describe the bug

Hello,

I would like to report a security vulnerability in private, I was not able to find a security contact for this repository and there is no security policy and private reporting is disabled as well. What would be a good contact to reach out to? Or would you be open to enabling Github's private vulnerability reporting for the repository?

๐Ÿ“š To reproduce

N/A

๐Ÿ’ก Expected behavior

N/A

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

v1.17

๐Ÿ“‹ Additional context

No response

`latest` is no longer adding labels

๐Ÿž Describe the bug

I have this setup for a number of repositories. I was using latest and I've also tried @v1

This was working last time I added changes.

๐Ÿ“š To Reproduce

Run workflow with labels specified

๐Ÿ’ก Expected behavior

The label should be added to the PR

๐Ÿ–ผ๏ธ Screenshots

Here is one of the PRs from the last couple runs with latest and @v1: PR

I tried running multiple times and the label is not added.

โš™๏ธ Environment

  • Action version: latest

Reporting a vulnerability

Hello!

I hope you are doing well!

We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.

Can you enable it, so that we can report it?

Thanks in advance!

PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository

Error when sync an empty file

๐Ÿž Describe the bug

When synchronize a file which is empty I have the following errors :

Synchronize Files
Cannot read property 'startsWith' of undefined

Synchronize Files
TypeError: Cannot read property 'startsWith' of undefined

๐Ÿ“š To Reproduce

Create a file with no content.
I created an empty docker-compose.yaml file

๐Ÿ’ก Expected behavior

I expected to have my file syncronized

๐Ÿ–ผ๏ธ Screenshots

โš™๏ธ Environment

  • Action version: [e.g. v1.0.0]

๐Ÿ“‹ Additional context

Add any other context about the problem here.

Error: stdout maxBuffer length exceeded

๐Ÿž Describe the bug

Similar to #174 but using the latest available version (v1.17.21 at the time of writing this).

When running the action across a number of a repos, several return the error Error: stdout maxBuffer length exceeded.

With debug logging enabled:

##[debug]EXEC: "git ls-tree -r --full-tree f90ff334cb91728ae54ce0311e374dda2d904ccc" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
Error: stdout maxBuffer length exceeded
##[debug]{"code":"ERR_CHILD_PROCESS_STDIO_MAXBUFFER","cmd":"git ls-tree -r --full-tree f90ff334cb91728ae54ce0311e374dda2d904ccc"}
Repository Info
Slug		: github-app-installation-token
Owner		: sammcj
Https Url	: https://github.com/sammcj/github-app-installation-token

Repo: https://github.com/sammcj/check-renamed-files-action

๐Ÿ“š To reproduce

I believe you could fork https://github.com/sammcj/check-renamed-files-action and try syncing files to it.

๐Ÿ’ก Expected behavior

Not fail on error.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

v1.17.21

๐Ÿ“‹ Additional context

 ##[debug]CP: sync-files/dotfiles/actions-repos/.gitignore TO tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main/.gitignore
##[debug]EXEC: "git add -f ".gitignore"" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
##[debug]EXEC: "git status --porcelain" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
##[debug]Creating commit for file(s) .gitignore
##[debug]EXEC: "git commit -m 'chore: Sync Files - 2022/10/02 -- [bot] Synced local '\''.gitignore'\'' with remote '\''sync-files/dotfiles/actions-repos/.gitignore'\'''" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
##[debug]EXEC: "git status --porcelain" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
Pushing changes to target repository
##[debug]EXEC: "git log --format=%H --reverse main..HEAD" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
##[debug]EXEC: "git log -1 --format=%B f90ff334cb91728ae54ce0311e374dda2d904ccc" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
##[debug]EXEC: "git ls-tree -r --full-tree f90ff334cb91728ae54ce0311e374dda2d904ccc" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
##[debug]Creating missing blobs on GitHub
##[debug]EXEC: "git ls-tree -r --full-tree f90ff334cb91728ae54ce0311e374dda2d904ccc~1" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
##[debug]EXEC: "git ls-tree -r --full-tree f90ff334cb91728ae54ce0311e374dda2d904ccc" IN tmp-1664748747018/github.com/sammcj/check-renamed-files-action@main
Error: stdout maxBuffer length exceeded
##[debug]{"code":"ERR_CHILD_PROCESS_STDIO_MAXBUFFER","cmd":"git ls-tree -r --full-tree f90ff334cb91728ae54ce0311e374dda2d904ccc"}
Repository Info
Slug		: github-app-installation-token
Owner		: sammcj
Https Url	: https://github.com/sammcj/github-app-installation-token
Branch		: main

Exclude no longer works on version v1.18.00

๐Ÿž Describe the bug

When syncing folders between two repos suddenly the exclude functionality no longer works.

My code:

  • source : ais/groeps
    dest : docs/ais
    • source : ais
      dest : ais
      exclude: |
      groeps
      docs

When syncing the source ais folder to destination folder ais the groeps and docs subfolders are also synced and should be ignored.

This worked perfectly prio to 18/11/2022 around 11:41AM GMT+1 ?

๐Ÿ“š To reproduce

Removing the code below stops syncing the mentioned subfolders :

  • source : ais
    dest : ais
    exclude: |
    groeps
    docs

When I re-aply the code, the groeps and docs folders are synced again (exclude is ignored).

๐Ÿ’ก Expected behavior

The groeps and docs folders should not be synced as they are defined in the exclude list.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

Current runner version: '2.299.1'

๐Ÿ“‹ Additional context

No response

`deleteOrphaned` Option Doesn't Delete Hidden Files

๐Ÿž Describe the bug

With deleteOrphaned enabled, files beginning with . are not deleted from the synced directory.

๐Ÿ“š To Reproduce

Create the following folder structure:

Sync Repository

docker/
    Dockerfile

Target Repository

docker/
    .env

Sync the entire docker/ folder with deleteOrphaned set to true.

๐Ÿ’ก Expected behavior

deleteOrphaned should delete every file within the target repo which isn't also in the sync repo. In the example above, .env is missed.

๐Ÿ–ผ๏ธ Screenshots

If applicable, add screenshots to help explain your problem.

โš™๏ธ Environment

  • Action version: latest

๐Ÿ“‹ Additional context

N/A

Sync subfolder to destination

๐Ÿž Describe the bug

I would like to sync a subfolder from the direct_sync_to_root_of_repo to the destination .github folder:

.
โ””โ”€โ”€ direct_sync_to_root_of_repo
    โ””โ”€โ”€ .github
        โ””โ”€โ”€ metaconfig.yaml

This however creates a PR under direct_sync_to_root_of_repo/.github/metaconfig.yaml.

๐Ÿ“š To reproduce

group:
  - files:
    - source: direct_sync_to_root_of_repo/
      dest: ./
      template: false

๐Ÿ’ก Expected behavior

Exact folder hierarchy syned to destination.

๐Ÿ–ผ๏ธ Screenshots

No response

โš™๏ธ Environment

v1.21.0

๐Ÿ“‹ Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.