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

Action does not get triggered for last commit when base branch is changed #980

Closed
R1j1t opened this issue Feb 10, 2021 · 13 comments
Closed
Labels
bug Something isn't working

Comments

@R1j1t
Copy link

R1j1t commented Feb 10, 2021

Describe the bug
When the base branch of the PR is changed, action does not get triggered for the last commit in that PR.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Pull Request
  2. Change the base branch for which actions should be triggered for PR
  3. No ci trigger

Expected behavior
what I was expecting was actions to be triggered for the last commit in the PR. Wanted to check if it is not the expected behavior.

Runner Version and Platform

Version of your runner? Public Github

OS of the machine running the runner? OSX/Windows/Linux/...
NA

What's not working?

Github action not getting triggered.

Job Log Output

R1j1t/contextualSpellCheck#49 (comment) link to base branch change in PR.

Runner and Worker's Diagnostic Logs

NA

@R1j1t R1j1t added the bug Something isn't working label Feb 10, 2021
@R1j1t
Copy link
Author

R1j1t commented Feb 10, 2021

Please let me know if this is the right repository for this issue.

@thboop
Copy link
Collaborator

thboop commented Feb 10, 2021

Hey @R1j1t ,

The pull request event has a variety of triggers, by default we subscribe to opened, synchronize, or reopened. You can read more about those here: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request

Changing the base ref is the edited action, you can subscribe to those as well by doing

name: CI
on:
  pull_request:
    types: [synchronize, opened, reopened, edited]

However, edited applies to more than just changing the base ref, for example changing the title of the pr will also trigger the edited action.

You may filter these down using expressions, the github context stores information about why the edited event was triggered, for example:

    "event": {
      "action": "edited",
      "changes": {
        "base": {
          "ref": {
            "from": "main"
          },
          "sha": {
            "from": "{some sha here}"
          }
        }
      },

For more information on how to filter jobs based on the value of the context, please see our official docs

I've brought feedback to the team that we should consider an event for only base ref changes as an enhancement and add it by default, but it's not currently available and I don't have a timeline for when it may be available.

I'm going to close this issue for now, but feel free to reopen it if you have any more questions!

@thboop thboop closed this as completed Feb 10, 2021
@R1j1t
Copy link
Author

R1j1t commented Feb 11, 2021

Thanks @thboop for the detailed explanation. It definitely answers all the question I had. I will check the documentation to learn more about it. I really appreciate the quick response!

@AllanOricil
Copy link

AllanOricil commented Dec 10, 2021

@thboop help me with this issue. For some reason Im editing the Title of the PR and it does not start the action. Sometimes it does, but I can't understand why it does it sometimes.

https://github.community/t/action-not-starting-when-editing-the-title-or-description-of-a-pr/216836

@michalinacienciala
Copy link

michalinacienciala commented Apr 14, 2022

Hi @thboop, the doc you linked (https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request) refers to https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request for more information on activity types. In that doc about webhook events, the synchronize activity is described as this:

Triggered when a pull request's head branch is updated. For example, when the head branch is updated from the base branch, when new commits are pushed to the head branch, or when the base branch is changed.

Is that fragment of documentation out-of-date?

@LinusU
Copy link

LinusU commented Oct 3, 2022

@thboop has there been any more talks internally about adding this as a default?

It's quite surprising that workflow doesn't get triggered when the base branch is changed with e.g. the following configuration:

on:
  pull_request:
    branches:
    - master

duckdoom4 added a commit to renpy/vscode-language-renpy that referenced this issue Jun 14, 2023
I accidentally selected master as base branch when creating the PR. When changing this to develop, the checks where not triggered. To fix this I added the `edited` type, which is used when changing the base ref.

See actions/runner#980
duckdoom4 added a commit to renpy/vscode-language-renpy that referenced this issue Jun 14, 2023
I accidentally selected master as base branch when creating the PR. When changing this to develop, the checks where not triggered. To fix this I added the `edited` type, which is used when changing the base ref.

See actions/runner#980
@cakeinpanic
Copy link

@michalinacienciala I assume that "base branch is changed" means not that new commits are pushed to master, but master is replaced with dev or smth ike this

@fsmanuel
Copy link

fsmanuel commented Sep 14, 2023

@cakeinpanic in my case it happens if you base a PR on another PR and the first PR gets merged. Github changes the base of the second to main automatically but github actions is not triggered.

With a similar configuration like @LinusU

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

@angiarao
Copy link

what happens if a base branch is rebased along with new commits? what would be event that would be triggered here? Apologies for asking question on a closed thread.

@AllanOricil
Copy link

AllanOricil commented Nov 20, 2023

what happens if a base branch is rebased along with new commits? what would be event that would be triggered here? Apologies for asking question on a closed thread.

If your workflow is sub to pull_request.edited, then it should be triggered when changing base:HEAD because the base name is just an alias for the commit sha, and the commit sha has changed.

"event": { "action": "edited", "changes": { "base": { "ref": { "from": "main" }, "sha": { "from": "{some sha here}" } } },

the event would have a different base.sha.from

@angiarao
Copy link

So to confirm, in the below workflow
create pr -> rebase from master -> add new commits -> force push to update the PR
it should trigger edited event?

@AllanOricil
Copy link

So to confirm, in the below workflow
create pr -> rebase from master -> add new commits -> force push to update the PR
it should trigger edited event?

You changed your question. You would need a different event. It depends on if you want to trigger on push or pr, when changing your source branch.

aherrmann added a commit to aherrmann/rules_zig that referenced this issue Apr 16, 2024
As documented in
actions/runner#980 (comment)

This occurs when a PR is marked as depending on another PR, has that
other PR's branch as its base branch, and GitHub then automatically
changes the base branch after the first PR is merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants