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

squash and merge tags original branch not new target #215

Closed
nmichlo opened this issue Nov 28, 2022 · 6 comments
Closed

squash and merge tags original branch not new target #215

nmichlo opened this issue Nov 28, 2022 · 6 comments

Comments

@nmichlo
Copy link
Contributor

nmichlo commented Nov 28, 2022

Not sure if I am missing an obvious config setting, but squashing and merging, instead of a plain merge tags the original commit on the old branch from a PR rather than the new squashed and merged commit on our main branch.

@sbe-arg
Copy link
Collaborator

sbe-arg commented Nov 28, 2022

I think you are right

@nmichlo
Copy link
Contributor Author

nmichlo commented Nov 29, 2022

Thank you for your response.

Figured out the solution in the meantime. It's to change the ref for the second config in the readme to ${{ github.sha }} instead of the reference to the PR's head sha

Maybe a note can be added there for future users? Seems to be working fine now.

EDIT: this should actually be ${{ github.event.pull_request.merge_commit_sha }}, with the additional line if: github.event.pull_request.merged == true added too, please see below

@sbe-arg
Copy link
Collaborator

sbe-arg commented Dec 4, 2022

Updated example in this pr #218

@nmichlo
Copy link
Contributor Author

nmichlo commented Dec 7, 2022

Thank you! Although I have found an additional error:

...

name: version bump
on:
  pull_request:
    types:
      - closed
    branches:
      - main

jobs:
  build:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.merge_commit_sha }}
          fetch-depth: "0"

...

After looking at the GitHub docs, this is probably the correct reference to use for PR. ${{ github.event.pull_request.merge_commit_sha }} Not the original one I posted. (The original will probably work, but might be more error prone)

I also needed to add the if statement if: github.event.pull_request.merged == true which makes sure that the PR is actually merged, and not only closed (cancelled). Previously it was tagging the wrong branch too when it was not yet merged but just cancelled.

@sbe-arg
Copy link
Collaborator

sbe-arg commented Dec 11, 2022

Mind opening a pr with improved readme examples?

nmichlo added a commit to nmichlo/github-tag-action that referenced this issue Dec 13, 2022
Fix example based on discussion in anothrNick#215
@nmichlo
Copy link
Contributor Author

nmichlo commented Dec 13, 2022

Sure thing @sbe-arg, I've opened the following PR:

sbe-arg pushed a commit that referenced this issue Jun 20, 2023
* Update README.md

Fix example based on discussion in #215

* Update README.md

Revert qoutes to match original config
@sbe-arg sbe-arg closed this as completed Jun 20, 2023
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

2 participants