The clean argument (which executes git clean -ffdx && git reset --hard HEAD) is insufficient for cleaning up a previous branch's submodule state. git clean will not remove the submodule's folder since it is checked in, meaning that it remains in the repo as untracked state when you checkout a different branch which does not contain the submodule. I resolved this by cleaning after checkout as well:
- uses: actions/checkout@v4
# Because each invocation is not in an isolated environment, we need to force clean
# AFTER checkout to remove any stale submodule state from a previous branch's run.
- name: Clean git state
run: git clean -ffdx
The
clean
argument (which executesgit clean -ffdx && git reset --hard HEAD
) is insufficient for cleaning up a previous branch's submodule state.git clean
will not remove the submodule's folder since it is checked in, meaning that it remains in the repo as untracked state when you checkout a different branch which does not contain the submodule. I resolved this by cleaning after checkout as well: