File tree Expand file tree Collapse file tree 4 files changed +14
-5
lines changed
Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,11 @@ Add a step like this to your workflow:
3636 # Default: 'Commit from GitHub Actions'
3737 message : ' Your commit message'
3838
39- # The arguments for the `git rm` command (see the paragraph below for more info)
39+ # Name of the branch to use, if different from the one that triggered the workflow
40+ # Default: the branch that triggered the workflow (from GITHUB_REF)
41+ ref : ' someOtherBranch'
42+
43+ # The arguments for the `git rm` command (see the paragraph below for more info)
4044 # Default: ''
4145 remove : " ./dir/old_file.js"
4246
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ inputs:
2424 description : The message for the commit
2525 required : false
2626 default : Commit from GitHub Actions
27+ ref :
28+ description : Name of the branch to use, if different from the one that triggered the workflow
29+ required : false
2730 remove :
2831 description : Arguments for the git rm command
2932 required : false
Original file line number Diff line number Diff line change @@ -44,14 +44,14 @@ if ! git diff --cached --quiet --exit-code; then
4444 git fetch
4545
4646 # Verify if the branch needs to be created
47- if ! git rev-parse --verify --quiet " ${GITHUB_REF : 11} " ; then
47+ if ! git rev-parse --verify --quiet " $INPUT_REF " ; then
4848 echo " Creating branch..."
49- git branch " ${GITHUB_REF : 11} "
49+ git branch " $INPUT_REF "
5050 fi
5151
5252 # Switch to branch from current workflow run
5353 echo " Switching branch..."
54- git checkout " ${GITHUB_REF : 11} "
54+ git checkout " $INPUT_REF "
5555
5656 echo " Pulling from remote..."
5757 git fetch && git pull
@@ -69,7 +69,7 @@ if ! git diff --cached --quiet --exit-code; then
6969 git commit -m " $INPUT_MESSAGE " --author=" $INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL >"
7070
7171 echo " Pushing to repo..."
72- git push --set-upstream origin " ${GITHUB_REF : 11} "
72+ git push --set-upstream origin " $INPUT_REF "
7373
7474 echo " ::endgroup::"
7575 echo " Task completed."
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ function checkInputs() {
2525 setDefault ( 'author_email' , 'actions@github.com' )
2626 }
2727
28+ setDefault ( 'ref' , process . env . GITHUB_REF ?. substring ( 11 ) || '' )
29+
2830 info ( `Using '${ getInput ( 'author_name' ) } <${ getInput ( 'author_email' ) } >' as author.` )
2931}
3032
You can’t perform that action at this time.
0 commit comments