Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong commit checked out by the second workflow in chain #1425

Open
mstrujic-cls opened this issue Aug 8, 2023 · 2 comments
Open

Wrong commit checked out by the second workflow in chain #1425

mstrujic-cls opened this issue Aug 8, 2023 · 2 comments

Comments

@mstrujic-cls
Copy link

Quick Summary

In case when pipeline is triggered by non-default branch and has more than one workflow chained, workflows after the first one will checkout the default branch even when triggered by a separate one.

I think we have issue 49 (or similar) returned (#49).

Steps

  • I have a branch "hotfix" created of main branch
  • I commit new change to the "hotfix" branch
  • I have two workflows (chained) to run when there is a change on both main and that second branch (test and build)
  • When change happens (commit), first workflow works with a proper GITHUB_SHA (or github.sha)
  • When second workflow starts, it pulls default branch last commit instead <--- ????

I tried to print both GITHUB_SHA and github.sha and both are pointing to the main branch (and not current branch that has triggered the pipeline).

This is a serious issue as if I wasn't using commit Id for application version tag it would deploy completely wrong version of the code to production. I would appreciate any idea or help how to go around this.

Workaround

I was able to avoid it by merging two workflows into one and adding conditionals to the second one (to mimmic on.workflow_run):

Previously the second workflow:

on:
  workflow_run:
     workflows:
       - My Workflow
     branches:
       - main
       - hotfix
     types:
       - completed

Added to the second job:

if: success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/hotfix')
@dogmatic69
Copy link

I've been having an issue with the wrong commit being used. I have multiple workflows but not sure that is the issue. When reverting to actions/checkout@v3.5.3 it works as expected again.

@Anubiso
Copy link

Anubiso commented Sep 8, 2023

We have the same issue using actions/checkout@v3. We are using multiple runners & multiple jobs in 1 pipeline and in some steps the source code is not the one from the triggering commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants