Skip to content

Action omits previous commits to branch #1173

@btrautmann

Description

@btrautmann

Subject of the issue

We have a use case where there are previous commits to the branch from which we're looking to open a PR. Unfortunately the behavior we're seeing is the following:

Scenario 1

  • job A checks out branch-a, makes a commit, and pushes it (this is an empty commit using --allow-empty but I don't believe this matters)
  • job B checks out branch-a and correctly sees this commit in git log, uses that commit for some implied versioning and uploads artifacts to be committed in the next job
  • job C checks out branch-a, downloads artifacts from job B, and attempts to commit them and open a PR using create-pull-request action from branch-a to main, but unfortunately only the commit made by create-pull-request itself is contained within the PR, and NOT the one from job A

Scenario 2
I also tested by adding an additional job B2 between B and C that downloaded the artifacts and committed them manually, THEN used create-pull-request without any commits specified to open the PR. In this case it said that the branch did not differ from the base branch main (i.e, neither the commits from job A or job B2 were respected/shown).

Steps to reproduce

Create a workflow that contains at least 1 job prior to this action being run that commits a code change onto the branch that will later be used as the branch input to this action. They're not included in the PR into base.

If this issue is describing a possible bug please provide (or link to) your GitHub Actions workflow. I can't do this bit as the repository is private

Edit/Update:

To prove to myself that this should indeed work, I left the workflow in the same shape it was, but migrated to using the github-script to open the PR.

  - name: Create pull request
    id: create_pull_request
    uses: actions/github-script@v6
    with:
      script: |
        const { repo, owner } = context.repo;
        const result = await github.rest.pulls.create({
          title: 'chore(release): Prep for next release',
          owner,
          repo,
          head: 'branch-a',
          base: 'main',
          body: [
            'This PR is auto-generated by',
            '[actions/github-script](https://github.com/actions/github-script).'
          ].join('\n')
        });

This worked as expected, and contained both commits from job A and job B2 in the second scenario above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions