Control GitHub Actions workflow execution to avoid infinite loops and unnecessary builds. Implement these practices: 1. **Add `paths-ignore` filters** for generated files that might trigger the workflow again:
Control GitHub Actions workflow execution to avoid infinite loops and unnecessary builds. Implement these practices:
paths-ignore
filters for generated files that might trigger the workflow again:on:
push:
branches: ["main"]
paths-ignore:
- version.txt # Skip when only version files change
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main # Explicitly reference the target branch
fetch-depth: 0
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: $
branch: trails # Explicitly specify the target branch
on:
push:
branches: [ "main" ]
# pull_request: # Remove if not needed for publishing operations
# branches: [ "main" ]
These practices ensure your workflows run only when needed and operate on the correct code, preventing wasteful CI resources and confusing version history.
Enter the URL of a public GitHub repository