There is a repo that has a submodule, in a workflow triggered by PR it commits and pushes changes to the submodule and after that, the workflow has a step to update the caller repo to get the latest changes in submodule.
Here is the code:
- name: Checkout submodule repo
uses: actions/checkout@v4
with:
repository: submodule_repository
path: submodule
token: ${{ env.GITHUB_TOKEN }}
fetch-depth: 0
persist-credentials: true
- name: Writes to submodule
run: |
python ./main.py
- name: Push changes to submodule
working-directory: submodule
run: |
git config user.name "name"
git config user.email "email"
git add .
git commit -m "Created or excluded DAG"
git push
- name: Checkout caller repo
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
path: caller
token: ${{ env.GITHUB_TOKEN }}
submodules: true
- name: Update caller repo to latest submodule
working-directory: caller
run: |
git config user.name "name"
git config user.email "email"
git submodule update --recursive --remote
git add .
git commit -m "Udpated submodule"
git push
${{ env.GITHUB_TOKEN }}
is a Github App.
The problem is, in the step Update caller repo to latest submodule
, when it pushes to the caller repo branch, it triggers the workflow again, creating a loop, that wasn’t suppose to happen according to this doc.
You can see the runs below, where the run number 151
was triggered by me creating a PR to main and the 152
was triggered by the push in the step Update caller repo to latest submodule
of the run number 151
: