After removing the following command git reset --hard origin/${GITHUB_REF#refs/heads/} || { echo "git reset failed"; exit 1; } from the trigger-jenkins-build.yml file, now the files old_build_number.txt and new_build_number.txt files are updated.
After updated the both text files, the changes are push back to the repository and that triggers Jenkins again these text files are updated and push that triggers Jenkins, it running continuously as a loop. How to update these text files after Jenkins build completed without pushing these changes to repository.
Note: This is the continuation to debug the issue of the Files are not updated after the Jenkins Build success triggered by the GitHub Actions
The trigger-jenkins-build.yml code is here
If you want the workflow to ignore updates to some paths you can add them to the trigger definition:
on:
push:
branches:
- "main"
paths-ignore:
- ".github/build_numbers/old_build_number.txt"
- ".github/build_numbers/new_build_number.txt"
See path-ignore documentation here.