Description
I am trying to achieve something that I am not sure is possible. I haven't been able to find any similar cases to mine, which is why I am creating this issue. The goal is to see if anyone has encountered this before and knows how to resolve it. I wouldn't say it's a problem per se, just a request for help.
Context
My repository has two git submodules and looks like this:
/src
/submodule_1
/submodule_2
My use case is a bit special because the repository is closely related to one of the git submodules. From now on, I will only mention the "git submodule" and ignore the other one since none of this concerns the other.
Basically, my workflow is triggered by pull requests, and I need to be able to clone the submodule and checkout to a branch with the same name (if a branch with the same name does not exist, master should be used).
This is how I try to checkout in the submodule:
cd submodule_folder
git fetch --all
git merge origin/master
# Try to checkout to branch with same name or master if it does not exist
git checkout -b "origin/$GITHUB_HEAD_REF" 2>&1 | grep -wi 'fatal' && git checkout master
git pull
Then after that, I need to execute some script from that submodule. The problem is I can't checkout to the branch I want (The branch exists in the origin of the git submodule repository, double-checked).
Action configuration:
# ....
# ....
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.ACCESS_TOKEN }}