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: 9 comments 6 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.
-
|
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…