admin管理员组

文章数量:1122832

There's this unanswered GitHub communities discussion about GitHub Actions pull_request events not being triggered when there are conflicts with the base branch set in the PR. The GitHub Actions team hasn't suggested a real solution to this issue for more than 5 years now.

I have GitHub Action that creates a Docker image and pushes it to an ECR repository. This is the scenario when the issue occurs:

             I--J   <-- feature/first_branch (HEAD)
            /
...--F--G--H--Z   <-- master

Commits J and Z are conflicted, and now the pull_request event in my GitHub Action won't be triggered since there's a conflict.

I know that push events don't have this issue, but I must use a pull_request event because I need to know what's the current branch's base branch because I cache-from the base branch's latest image.

I have a hack that works for me - I create another branch (feature/second_branch) that's based on feature/first_branch. Then I make a random commit that has no meaning so there'll be a diff between feature/second_branch and feature/first_branch (as GitHub doesn't allow opening PRs when there's no diff between the 2 branches you compare).

                  K--M   <-- feature/second_branch (HEAD)
                 /
             I--J   <-- feature/first_branch
            /
...--F--G--H--Z   <-- master

Once I open a PR where feature/first_branch is the base - I manage to trigger a pull_request event have a branch with the code I want and isn't conflicted with its base branch. That way there're no conflicts between them and I get my Docker image.

The problem with this hack is that I have no image to cache-from when feature/first_branch has no latest image pushed to the ECR (which is basically similar to triggering a push event in first place).

This issue doesn't happen on CircleCI flows, but I can't migrate this flow from GitHub Actions at the moment.

Is there a way to overcome this issue without any hacks, or at least a simpler hack than mine?

本文标签: