Reputation: 4274
To close a issue in Github via a PR you just need to add a key phrase like:
Closes #100
in the body of your PR and as soon as PR is merged into the default branch Github automatically closes the issue.
We merge our PR into branches under a version number (say branch 2.0.0
). but the issue remains open until we merge it into the default branch (in our case development
).
My question is how to setup the branch and/or PR so that after merging the PR into the (non-default) target branch, it closes the issue automatically.
Upvotes: 5
Views: 427
Reputation: 529
As the answer of this question says, an Issue will only close if it's merged into the main branch. There is no such option to do what you said in your question.
the referenced issue will automatically be closed when the PR is merged into the default branch
That's why in 4 years nobody could tell you how to do this.
I think that your question it's useful because such option should be available for cases like your one.
The only way right now is to do it manually.
close
buttonBut you could build an github action that does this automatically:
name: AutoIssue
on: # This you can set it up as you want, I made it trigger on a commit
push:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Merge Pull Request
uses: juliangruber/merge-pull-request-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: <NUM> # Enter here the pull request number you want to merge
method: squash
- name: Close Issue
uses: peter-evans/close-issue@v1
with:
issue-number: <NUM> # Enter here the issue number you want close
comment: Auto-closing issue
The only things you have to change are the <NUM>
placeholders
Upvotes: 1