peter-evans / create-pull-request

A GitHub action to create a pull request for changes to your repository in the actions workspace
MIT License
2.12k stars 414 forks source link

Pull requests containing change to git submodule can't be signed #3353

Closed gizmoguy closed 2 weeks ago

gizmoguy commented 2 weeks ago

Subject of the issue

If a pull request raised by this action contains a change to a git submodule when commit signing is enabled, an error occurs and the pull request is not created.

I think the error is caused here, where the action attempts to read the submodule directory to convert it to base64:

https://github.com/peter-evans/create-pull-request/blob/main/src/github-helper.ts#L265

Steps to reproduce

Here is a github action workflow which repros the issue:

---
name: Create pull request

on:
  workflow_dispatch:

jobs:
  create-pull-request:
    name: Create pull request with submodule
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Add git submodule
        run: |
          git submodule add https://github.com/actions/starter-workflows

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v7
        with:
          sign-commits: true

You can see the output of a failed run of this workflow here:

https://github.com/gizmoguy/create-pull-request-signed-test/actions/runs/10912635430/job/30287661070

The error is this:

Pushing pull request branch to 'origin/create-pull-request/patch'
  /usr/bin/git stash push --include-untracked
  Ignoring path starter-workflows/
  Saved working directory and index state WIP on main: 4ae0eb8 Add create pull request workflow
  /usr/bin/git checkout --progress create-pull-request/patch --
  Switched to branch 'create-pull-request/patch'
  Your branch and 'origin/create-pull-request/patch' have diverged,
  and have 2 and 6 different commits each, respectively.
    (use "git pull" if you want to integrate the remote branch with yours)
  Creating tree objects for local commit f1f261260ae4df8ac52497d66b9daa2d303f925b
  Error: Error creating blob for file 'starter-workflows': EISDIR: illegal operation on a directory, read
  Error: EISDIR: illegal operation on a directory, read
peter-evans commented 2 weeks ago

Hi @gizmoguy

Thank you for raising this issue and providing clear info on how to reproduce it! I'll take a look at how to fix this.

peter-evans commented 2 weeks ago

Released a fix for this in v7.0.4 / v7

Thanks again!

gizmoguy commented 2 weeks ago

Can confirm that I'm able to now sign commits that contain submodules, thanks for the quick fix!