add-and-commit icon indicating copy to clipboard operation
add-and-commit copied to clipboard

Support for sparse commit after sparse checkout

Open QuentiumYT opened this issue 4 months ago • 12 comments

When I checkout my repository, I use

      - uses: actions/checkout@v4
        with:
          ref: ${{ github.ref }}
          sparse-checkout: urls.txt

After all the action steps, I do git add --sparse results and commit

I tried to replace my commits with your actions but it seems like it doesn't support sparse, would like to know if you can add that?

      - uses: EndBug/add-and-commit@v9
        with:
          add: "results"
          pull: "--rebase --autostash ..."
          default_author: "github_actions"
          message: "update: ${{ matrix.sites.url }}"
[Scan (<action>)]
Error: The following paths and/or pathspecs matched paths that exist
outside of your sparse-checkout definition, so will not be
updated in the index:
results
hint: If you intend to update such entries, try one of the following:
hint: * Use the --sparse option.
hint: * Disable or modify the sparsity rules.
hint: Disable this message with "git config set advice.updateSparsePath false"

QuentiumYT avatar Sep 02 '25 07:09 QuentiumYT

Have you tried this?

with:
  add: "--sparse results"

EndBug avatar Sep 02 '25 15:09 EndBug

Will try that thanks :)

QuentiumYT avatar Sep 02 '25 18:09 QuentiumYT

A bit different now:

Add input parsed as single string, running 1 git add command.
> Using 'github-actions <123456789+github-actions[bot]@users.noreply.github.com>' as author.
> Using "update: site" as commit message.
Internal logs
  > Staging files...
  > Adding files...
  > No files to remove.
  > Checking for uncommitted changes in the git working tree...
  > Found 12 changed files.
  > Fetching repo...
  {
    raw: '',
    remote: 'https://github.com/<owner>/<repo>',
    branches: [ { name: 'gh-pages', tracking: 'origin/gh-pages' } ],
    tags: [],
    updated: [],
    deleted: []
  }
  > Pulling from remote...
  {
    raw: '',
    remote: null,
    branches: [],
    tags: [],
    updated: [],
    deleted: []
  }
  Error: Error: Could not read from remote repository.
Outputs
  committed: false
  commit_long_sha: undefined
  commit_sha: undefined
  pushed: false
  tagged: false
  tag_pushed: false
Error: Error: Could not read from remote repository.

QuentiumYT avatar Sep 03 '25 07:09 QuentiumYT

Hmm that's weird, can you share the workflow file and/or a link to the logs (if the repo is public) The weird part is remote: 'https://github.com/<owner>/<repo>',, it looks like something is misconfigured in the previous steps

EndBug avatar Sep 03 '25 08:09 EndBug

Well it's a public repo but I don't want to link any thing about it. That's why I replaced it with and Will create a example repo to reproduce

QuentiumYT avatar Sep 03 '25 10:09 QuentiumYT

Here is a basic repository example https://github.com/Quentium-Forks/action-commit-sparse

Workflow: https://github.com/Quentium-Forks/action-commit-sparse/actions/runs/17436737200/job/49508500697

QuentiumYT avatar Sep 03 '25 14:09 QuentiumYT

@QuentiumYT Sorry for the late reply, had a couple of busy weeks: can you run the workflow in debug mode?

EndBug avatar Sep 15 '25 08:09 EndBug

Hello, no problem, here it the job https://github.com/Quentium-Forks/action-commit-sparse/actions/runs/17436737200/job/50368076944

QuentiumYT avatar Sep 15 '25 08:09 QuentiumYT

Any update @EndBug? Thanks

QuentiumYT avatar Nov 07 '25 13:11 QuentiumYT

Hi I just had a look but honestly I don't know It's really weird that it happens only with sparse checkout, so either actions/checkout is doing something funny when doing that kind of checkout, or my action is experiencing a side effect from any of the git commands.

You could try seeing if running the commands manually causes the same issue

EndBug avatar Nov 07 '25 14:11 EndBug

Hi, well I don't really know about the generated git commands from either actions/checkout nor EndBug/add-and-commit, is there any logs?

QuentiumYT avatar Nov 07 '25 17:11 QuentiumYT

My action just logs the parsed arguments, the commands are pretty basic, just append the arguments to checkout, pull, fetch etc I don't know about actions/checkout, you could try just running a sparse checkout command to see what happens

EndBug avatar Nov 10 '25 07:11 EndBug