question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create PR is failing when using submodules (but only changes in the root repo)

See original GitHub issue

Subject of the issue

Hi, we are using submodules and this action. We are only doing changes to the “root” repo and not any submodule. When its time to create the PR it fails:

# ... everything works
/usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --unshallow --force origin auto-updater/patch:refs/remotes/origin/auto-updater/patch
# ^ works
/usr/bin/git checkout --progress auto-updater/patch --
  error: The following untracked working tree files would be overwritten by checkout:
  	my-submodule/file1.txt
  	my-submodule/file2.txt

This is probably because of the --no-recurse-submodules setting.

Steps to reproduce

workflow

- uses: actions/checkout@v3
  with:
    submodules: true
    token: ${{ secrets.MY_TOKEN }}

- run: date > test.txt

- name: Create pull request
  uses: peter-evans/create-pull-request@v4
  with:
    ...

Any help is appreciated!

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
peter-evanscommented, Oct 26, 2022

Ok, understood. I will look at finding a way to fix this when I have some time.

In the meantime, there is a potential workaround. This is how it works:

  1. Separate the workflow into two jobs, the second job depending on the first using the needs: keyword
  2. In the first job, checkout the submodules and create the repository changes.
  3. At the end of the first job, use upload-artifact to store the changes.
  4. In the second job, run checkout only for the root repo, without the submodules.
  5. Use download-artifact to copy the changes created in the first job over the local repo.
  6. Execute create-pull-request
0reactions
peter-evanscommented, Nov 30, 2022

I’ve made the test repository I was using public. You can have a look at the tests and runs here: https://github.com/peter-evans/cpr-submodules/blob/main/.github/workflows/test.yml

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git will not init/sync/update new submodules
When a repo with submodules has been set up correctly and someone ... PS: Make sure you are in the root git directory,...
Read more >
Git Submodules: Adding, Using, Removing, Updating
Basically I'd like to pull some libraries as submodules within my main repository and using your approach made this easy. However, I'd now...
Read more >
Issues · peter-evans/create-pull-request
A GitHub action to create a pull request for changes to your repository ... Create PR is failing when using submodules (but only...
Read more >
Effectively Working with Git Submodules
Therefore we found it better to switch to submodule repository and create branch there, make changes, add unit tests, verify, create PR, review ......
Read more >
Mastering Git submodules
Only later do all the pitfalls and traps come and bite everyone, every day. ... Working around this by littering your submodule repo...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found