question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avoid workflow get launched after commit in a loop !

See original GitHub issue

Describe the bug I am using EndBug/add-and-commit@v5 but it launches a loop of Github Actions because, everytime there is a change the workflow get launched.

There is no support for that, and it looks like every body is gonna have the same issue.

Workflow used

name: Workflow branch master
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build:
    name: Build and push image
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          token: ${{ secrets.REPO_TOKEN }}
      - name: Upgrade the version
        run: |
          VERSION=$(grep -oP '(?<=latest-)[0-9]+' ./.github/workflows/build-and-push-image-to-registry.yaml)
          OLD_VERSION=$VERSION
          NEW_VERSION=$(($VERSION + 1))
          sed -i "s/latest-$OLD_VERSION/latest-$NEW_VERSION/g" ./scaleway/values.yaml
          sed -i "s/latest-$OLD_VERSION/latest-$NEW_VERSION/g" ./.github/workflows/build-and-push-image-to-registry.yaml
      - name: Commit changes
        uses: EndBug/add-and-commit@v5
        with:
          message: "Robot version upgrade"
          add: "."
        env:
          GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}

Expected behavior I wanna launch this workflow only if commit message is Robot version upgrade

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
tomtom94commented, Dec 6, 2020

Ok apparently you just need to use the if condition

jobs:
  build:
    name: Build and push image
    runs-on: ubuntu-latest
    if: github.event.head_commit.message != 'Robot version upgrade'
1reaction
thomas-rkkcommented, Oct 7, 2021

Thanks for the solution to this issue, I would expect it to be quite common. You can also do if: github.event.head_commit.author.name != 'github-actions' for example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

github - Triggering a workflow run after an action commits
we have an action (runs manually) that commits to the pull-request (updating some files in the branch). when the second action finishes to...
Read more >
trigger + workflow field change = infinite loop?
I'm trying to "prove" that triggers are done before workflows. So, in my trigger, I have it update a field "WhoIsLast" with the...
Read more >
7 Github Actions Tricks I Wish I Knew Before I Started
#2: Reusable Workflows with Workflow Calls. Triggers are great, but this one gets a full title of its own. Now let's say you've...
Read more >
Salesforce Flow Loops - Best Practices and Examples
To do this, create a Loop after the Get Records element. Use the Collection that was created in the Get Records element.
Read more >
Looping within a Workflow Process - Oracle Blogs
This blog post contributed by Ajay Verma. ... Get Recipient Logic ... long running workflow loop can be easily avoided as done in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found