Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for --amend. #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
push-branch: 'master'
commit-message: 'publish'
force-add: 'true'
commit-amend: false
force-add: true
files: a.txt b.txt c.txt dirA/ dirB/ dirC/a.txt
name: commiter name
email: [email protected]
Expand Down
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ inputs:
description: 'Specify commit message'
required: false
default: 'autocommit'
commit-amend:
description: 'Amend a previous commit.'
required: false
default: false
force-add:
description: 'Force add files, useful for adding ignored files.'
required: false
default: 'false'
default: false
force-push:
description: 'Force push.'
required: false
default: 'false'
default: false
rebase:
description: 'Pull and rebase before commiting. Useful when using commit inside matrix.'
required: false
default: 'false'
default: false
files:
description: 'Specific files to add.'
required: false
Expand Down
11 changes: 10 additions & 1 deletion entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def run():
github_actor = local.env.get('GITHUB_ACTOR')
github_token = local.env.get('INPUT_GITHUB-TOKEN')
commit_message = local.env.get('INPUT_COMMIT-MESSAGE')
commit_amend = local.env.get('INPUT_COMMIT-AMEND')
force_add = local.env.get('INPUT_FORCE-ADD')
force_push = local.env.get('INPUT_FORCE-PUSH')
branch = local.env.get('INPUT_PUSH-BRANCH') or "/".join(local.env.get('GITHUB_REF').split('/')[2:])
Expand Down Expand Up @@ -51,7 +52,15 @@ def run():
push_args.append('--force')
debug(git(['checkout', '-B', branch]))
debug(git(add_args))
debug(git(['commit', '-m', commit_message], retcode=None))
commit_args = ['commit']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yuehvdbjioolaurenknowseverything!:)

if commit_message:
commit_args.append('-m')
commit_args.append(commit_message)
else:
commit_args.append('--no-edit')
if commit_amend:
commit_args.append('--amend')
debug(git(commit_args, retcode=None))
debug(git(push_args))

if __name__ == '__main__':
Expand Down