Skip to content

Commit 2ee7360

Browse files
flxdotflxdot
and
flxdot
authored
Add ability to pull before push (#23)
* Add ability to pull before push * make rebase explicit * revert change --------- Co-authored-by: flxdot <felix.fanghaenel@nitrex.com>
1 parent 156f2b1 commit 2ee7360

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
| amend | boolean | false | Determines if the commit should be amended. Needs to be used with `force` input to force push the amended commit. |
4848
| force | boolean | false | Determines if force push is used. |
4949
| tags | boolean | false | Determines if `--tags` is used. |
50+
| rebase | boolean | false | Determines if `git pull --rebase` is used before the push. This is useful if multiple actions try to push at the same time. |
5051
| directory | string | '.' | Directory to change to before pushing. |
5152
| repository | string | '' | Repository name. Default or empty repository name represents current github repository. If you want to push to other repository, you should make a [personal access token](https://github.com/settings/tokens) and use it as the `github_token` input. |
5253

action.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,28 @@ inputs:
2323
description: 'Commit message.'
2424
required: false
2525
repository:
26-
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})'
26+
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY}).'
2727
default: ''
2828
required: false
2929
branch:
30-
description: 'Destination branch to push changes'
30+
description: 'Destination branch to push changes.'
3131
required: false
3232
default: 'main'
3333
empty:
34-
description: 'Allow empty commit'
34+
description: 'Allow empty commit.'
3535
required: false
3636
amend:
37-
description: 'Determines if the commit should be amended'
37+
description: 'Determines if the commit should be amended.'
3838
required: false
3939
default: 'false'
4040
force:
41-
description: 'Determines if force push is used'
41+
description: 'Determines if force push is used.'
4242
required: false
4343
tags:
44-
description: 'Determines if --tags is used'
44+
description: 'Determines if --tags is used.'
45+
required: false
46+
rebase:
47+
description: 'Determines if `git pull --rebase` is used before the push. This is useful if multiple actions try to push at the same time.'
4548
required: false
4649
directory:
4750
description: 'Directory to change to before pushing.'

start.sh

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ INPUT_BRANCH=${INPUT_BRANCH:-master}
1212
INPUT_AMEND=${INPUT_AMEND:-false}
1313
INPUT_FORCE=${INPUT_FORCE:-false}
1414
INPUT_TAGS=${INPUT_TAGS:-false}
15+
INPUT_REBASE=${INPUT_REBASE:-false}
1516
INPUT_EMPTY=${INPUT_EMPTY:-false}
1617
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
1718
REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
@@ -66,4 +67,8 @@ else
6667
git commit -m "${INPUT_MESSAGE}" $_EMPTY || exit 0
6768
fi
6869

70+
if ${INPUT_REBASE}; then
71+
git pull --rebase
72+
fi
73+
6974
git push "${remote_repo}" HEAD:"${INPUT_BRANCH}" --follow-tags $_FORCE_OPTION $_TAGS;

0 commit comments

Comments
 (0)