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:
36
36
# Default: 'Commit from GitHub Actions'
37
37
message : ' Your commit message'
38
38
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)
40
44
# Default: ''
41
45
remove : " ./dir/old_file.js"
42
46
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ inputs:
24
24
description : The message for the commit
25
25
required : false
26
26
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
27
30
remove :
28
31
description : Arguments for the git rm command
29
32
required : false
Original file line number Diff line number Diff line change @@ -44,14 +44,14 @@ if ! git diff --cached --quiet --exit-code; then
44
44
git fetch
45
45
46
46
# 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
48
48
echo " Creating branch..."
49
- git branch " ${GITHUB_REF : 11} "
49
+ git branch " $INPUT_REF "
50
50
fi
51
51
52
52
# Switch to branch from current workflow run
53
53
echo " Switching branch..."
54
- git checkout " ${GITHUB_REF : 11} "
54
+ git checkout " $INPUT_REF "
55
55
56
56
echo " Pulling from remote..."
57
57
git fetch && git pull
@@ -69,7 +69,7 @@ if ! git diff --cached --quiet --exit-code; then
69
69
git commit -m " $INPUT_MESSAGE " --author=" $INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL >"
70
70
71
71
echo " Pushing to repo..."
72
- git push --set-upstream origin " ${GITHUB_REF : 11} "
72
+ git push --set-upstream origin " $INPUT_REF "
73
73
74
74
echo " ::endgroup::"
75
75
echo " Task completed."
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ function checkInputs() {
25
25
setDefault ( 'author_email' , '[email protected] ' )
26
26
}
27
27
28
+ setDefault ( 'ref' , process . env . GITHUB_REF ?. substring ( 11 ) || '' )
29
+
28
30
info ( `Using '${ getInput ( 'author_name' ) } <${ getInput ( 'author_email' ) } >' as author.` )
29
31
}
30
32
You can’t perform that action at this time.
0 commit comments