Endless cycle of github actions initiated by a build #74772
-
Select Topic AreaQuestion BodyI have a repo for which github actions is configured.
This continuous loop of github actions is persisting. Is there any possible solution? Note: I have not been able to include an if condition to halt the build if the GH action is triggered by a different user, on a different branch, or by a different actor. Nevertheless, the GH action employs my own ID and token to commit the PDF file. Is there any other condition to check if the commit is triggered by GH action based on which I can stop the infinite loop ? |
Beta Was this translation helpful? Give feedback.
Replies: 33 comments 55 replies
-
|
To prevent a GitHub Actions workflow from triggering itself in an infinite loop, you can use conditional checks within your workflow to determine if the commit was made by a GitHub Actions bot or by another user. If the commit was made by the bot, you can skip the rest of the job. Here is a common approach using the GITHUB_ACTOR and github.event contexts: In this example: github.actor provides the name of the person or app that initiated the workflow. If this is 'github-actions[bot]', then it means the workflow was triggered by GitHub Actions. Here's an example of how you can skip a job if the last commit message contains a specific keyword (like [skip ci] or some unique identifier): In this setup: The first step is to extract the last commit message and store it in an environment variable. |
Beta Was this translation helpful? Give feedback.
-
|
@ev1sl , thanks. that works! |
Beta Was this translation helpful? Give feedback.
-
|
I tried to reproduce a dead loop like this but failed: https://github.com/suzaku/github-actor-playground/blob/main/.github/workflows/blank.yml#L32-L37 |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
Hi @iamshreeram, To prevent the infinite loop caused by commits from your GitHub Action, add a conditional check to skip the workflow when the commit is made by the GitHub Actions bot itself: Option 1: Filter by actor in the workflow step - name: Commit PDF
if: github.event_name == 'push' && github.actor != 'github-actions[bot]'
run: |
git commit -m "Add generated PDF"
git push Option 2: Skip CI with commit message git commit -m "Update PDF [skip ci]" Option 3: Use a PAT from a bot account if: github.actor == 'your-bot-user' GitHub Actions skips workflows triggered by the default For more details: GitHub Docs on Skipping Workflows. Let me know if you need more help! |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
… On Wed, 16 Apr 2025, 02:11 md lassu, ***@***.***> wrote:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: ***@***.***
- name: Check last commit message
id: commit-message
run: echo "COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV
- name: Skip if commit is automated
if: contains(env.COMMIT_MESSAGE, '[skip ci]')
run: |
echo "Automated commit detected - skipping job"
exit 0jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.actor != 'github-actions[bot]' && github.event_name != 'push' || github.event.pusher.name != 'github-actions[bot]' }}
steps:
- name: Checkout code
uses: ***@***.***
# Your other steps...
—
Reply to this email directly, view it on GitHub
<#74772 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BRERO6GUWHJPVTED2GHFPMT2ZVYWHAVCNFSM6AAAAABLAHSKHGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEOBUG4YDIMQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Your other steps... # Your other steps... |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
{"version":"1.0.1","github_sha":"a4dbe621634a06596f5a929b9caa12d00e344844"} |
Beta Was this translation helpful? Give feedback.
-
|
{"version":"1.0.1","github_sha":"a4dbe621634a06596f5a929b9caa12d00e344844"}`` |
Beta Was this translation helpful? Give feedback.
-
jobs:build: |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
⏱️ Temps estimé : 15 minutesRésultat : Vous aurez :
🚨 Si le username "sifouchemam" est déjà pris :Essayez ces variations :
Commencez maintenant par l'étape 1 (github.com/signup), puis revenez si vous avez des questions spécifiques. |
Beta Was this translation helpful? Give feedback.
-
|
Pull request and add workflow and GitHub documentation |
Beta Was this translation helpful? Give feedback.
-
|
Don't use CSS or visual like implementations, one cannot actually imply a visual distribution of points on a variance of actions, it would require graphic design related factors. Unless it was exact to a project a little markdown explanation or pdf inclusion of an example or visual thematic look or feel, perhaps charts or statements of outcomes, while this can provide a framework, but there must be a formative process of including how a user produces a pdf within its own performance, eg. steps for the format of files in documentation transfer with or without safety templates in a basic on non-basic making. |
Beta Was this translation helpful? Give feedback.
-
|
applying a end of cycle at the completion result would be lawful. or lawsuit or illicit behavior can breach pdf related materials and processes Ings. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
To prevent a GitHub Actions workflow from triggering itself in an infinite loop, you can use conditional checks within your workflow to determine if the commit was made by a GitHub Actions bot or by another user. If the commit was made by the bot, you can skip the rest of the job.
Here is a common approach using the GITHUB_ACTOR and github.event contexts:
In this example:
github.actor provides the name of the pe…