adrianjost / files-sync-action

Files sync action for Github
https://github.com/marketplace/actions/files-sync-action
24 stars 12 forks source link

Sync Folder #251

Open blushell opened 1 year ago

blushell commented 1 year ago

Not sure if I am doing correct if is possible but i want just the content from folder from source repo to sync just to folder in target repo.

name: FASTDL Test

on: workflow_dispatch

jobs:
   fastdl_sync:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout FW Repo
        uses: adrianjost/files-sync-action@v2.0.4
        with:
          GITHUB_TOKEN: ${{secrets.TOKEN}}
          SRC_REPO: DarklandServers/fortwars
          SRC_ROOT: ./gamemodes/fortwarsremastered/content-compressed/
          TARGET_REPOS: DarklandServers/fastdl
          TARGET_ROOT: ./fw/
          DRY_RUN: false
adrianjost commented 1 year ago

You need to also specify the FilePatterns you want to sync from those folders.

note: please use proper formatting of code, to make reading your issues easier. You just need to add ``` before and after your code.

blushell commented 1 year ago

I had tried that. I may be still doing it wrong though. I would like all the files and sub folders from SRC path sync to path on target.

name: FASTDL Test

on: workflow_dispatch

jobs:
   fastdl_sync:
    name: Checkout FW Repo
    runs-on: ubuntu-latest
    steps:
      - name: Checkout dev repository
        uses: actions/checkout@v3
      - uses: adrianjost/files-sync-action@master
        with:
          GITHUB_TOKEN: ${{ secrets.TOKEN }}
          SRC_REPO: 'DarklandServers/fortwars'
          SRC_ROOT: '/gamemodes/fortwarsremastered/content-compressed/'
          FILE_PATTERNS: |
            ^gamemodes/fortwarsremastered/content-compressed/        
          TARGET_REPOS: |
            DarklandServers/fastdl
          TARGET_ROOT: '/fw/'
          DRY_RUN: false

I also tried ^gamemodes/fortwarsremastered/content-compressed/*

adrianjost commented 1 year ago

I'm not sure about what the code does anymore and my documentation about SRC_ROOT could be better. My guess is, that If you specify a SRC_ROOT your FILE_PATTERNS should be relative to this SRC_ROOT. So in this case, I guess it should be a RegExp that matches everything.

Try out the following and let me know if it works. if It does, a PR that clarifies the Documentation would be appreciated.

name: FASTDL Test

on: workflow_dispatch

jobs:
   fastdl_sync:
    name: Checkout FW Repo
    runs-on: ubuntu-latest
    steps:
      - name: Checkout dev repository
        uses: actions/checkout@v3
      - uses: adrianjost/files-sync-action@master
        with:
          GITHUB_TOKEN: ${{ secrets.TOKEN }}
          SRC_REPO: 'DarklandServers/fortwars'
          SRC_ROOT: '/gamemodes/fortwarsremastered/content-compressed/'
          FILE_PATTERNS: |
            .*        
          TARGET_REPOS: |
            DarklandServers/fastdl
          TARGET_ROOT: '/fw/'
          DRY_RUN: false
blushell commented 1 year ago

That does not seem to work. Its weird because it syncs everything from /gamemodes/fortwarsremastered/content-compressed/ to the /fw/ folder in the other repo. But it also syncs everything from root of src repo.

adrianjost commented 1 year ago

I have no immediate idea anymore. But I know that the config here works. It's almost the same use-case, but for specific files. Maybe there is a Syntax difference and you could look into it.

It would also help debugging, if you could narrow down the problem a bit further.

Currently the issue is just to broadly described to help you any further.

ReenigneArcher commented 6 months ago

I'm facing the same problem. I think the SRC_ROOT is being ignored for some reason. As far as I can interpret, this is the right syntax according to your example here (https://github.com/adrianjost/.github/blob/main/.github/workflows/sync.yml#L40)

    - uses: adrianjost/files-sync-action@v2.1.0
      with:
        COMMIT_MESSAGE: "Update ${{ github.repository }} to ${{ github.sha }}"
        FILE_PATTERNS: |-
          ^Formula/*.rb$
        GIT_EMAIL: ${{ secrets.git_email }}
        GIT_USERNAME: ${{ secrets.git_username }}
        GITHUB_TOKEN: ${{ secrets.git_pat}}
        SRC_ROOT: /tests/  # also tried with ${{ github.workspace }} as the prefix
        TARGET_REPOS: ${{ github.repository }}:tests
Run adrianjost/files-sync-action@v2.1.0
Context: {
  "COMMIT_MESSAGE": "Update LizardByte/homebrew-release-action to 20c180e8f938ada831c899728ac9a85f258437b4",
  "DRY_RUN": false,
  "FILE_PATTERNS": [
    {}
  ],
  "GITHUB_SERVER": "github.com",
  "GITHUB_TOKEN": "<secret>",
  "GIT_EMAIL": "***",
  "GIT_USERNAME": "***",
  "SKIP_CLEANUP": false,
  "SKIP_DELETE": false,
  "SKIP_REPLACE": false,
  "SRC_REPO": "LizardByte/homebrew-release-action",
  "SRC_ROOT": "/tests/",
  "TARGET_REPOS": [
    "LizardByte/homebrew-release-action:tests"
  ],
  "TARGET_ROOT": "/",
  "TMPDIR": "tmp-1709838547247"
}
EXEC: "GIT_LFS_SKIP_SMUDGE=1 git clone --depth 1 https://***@github.com/LizardByte/homebrew-release-action.git tmp-1709838547247/LizardByte/homebrew-release-action" IN "./"
OUTPUT STDOUT: none
FILE_PATTERNS [
  "/^Formula\\/*.rb$/"
]
MATCHING FILES: []
EXEC: "GIT_LFS_SKIP_SMUDGE=1 git clone --depth 1  -b tests https://***@github.com/LizardByte/homebrew-release-action.git tmp-1709838547247/LizardByte/homebrew-release-action-tests" IN "./"
OUTPUT STDOUT: none
FILE_PATTERNS [
  "/^Formula\\/*.rb$/"
]
MATCHING FILES: []
REMOVE FILES []
EXEC: "git status --porcelain" IN "tmp-1709838547247/LizardByte/homebrew-release-action-tests"
OUTPUT STDOUT: none
NO CHANGES DETECTED
adrianjost commented 6 months ago

@ReenigneArcher Your filepattern does not look quite right. /* matches a / 0-infinite many times, followed by . matching any character (but just once) and then ending on rb. So I think it is likely a different issue. You can test your regex using https://regex101.com/