I’m using github and github actions.
With the actions Create Issue Branch, it’s possible to automatically generate a branch when a user is assigned to the issue/ticket.
This works perfectly! When I have the standard file from the documentation: .github/workflows/create_branch.yml
:
on:
# The issue.opened event below is only needed for the "immediate" mode.
# The issue.assigned event below is only needed for the default ("auto") mode.
issues:
types: [ opened, assigned ]
# The issue_comment.created event below is only needed for the ChatOps mode.
issue_comment:
types: [ created ]
# The pull_request events below are only needed for pull-request related features.
pull_request:
types: [ opened, closed ]
jobs:
create_issue_branch_job:
runs-on: ubuntu-latest
steps:
- name: Create Issue Branch
uses: robvanderleek/create-issue-branch@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
However I need to pass in the setting branchName: '${issue.number}-${issue.title}'
to make a custom branchName .. So far I havn’t been able to find out where.. And in my attempt to pass in the setting, I broke the action.
Where should I put the variable branchName
in the `.yml’ file?
2
Answers
Given your current workflow file, to add a custom
branchName
, I believe you need to modify theCreate Issue Branch
step to include awith
section where you definebranchName
like this:In a similar setup I have,
${issue.number}
and${issue.title}
dynamically insert the issue number and title into the branch name.This action doesn’t take any inputs provided with
with
(see theiraction.yml
file).Instead, if you want to modify default behaviour, the action checks for a file
.github/issue-branch.yml
, and that is where you can set the branch name convention likeNotice that you have the indentation wrong in your snippet:
uses
must not be less indented thanname
for a step.And, not to take away from the creator of the action, but creating a branch seems to be simple enough to do it directly in a
run
step, something like