Skip to content

Adding push remote configuration #27

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

Closed
wants to merge 6 commits into from
Closed
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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
## commit
## Github Commit & Push Action

Git commit and push

### Options

* **github-token**: *Required*. Github Token with commit access. If pushing to the same repo the action is running on, please use `${{ secrets.GITHUB_TOKEN }}`. If for another repo, create a personal private token, add it to secrets then use it here.
* **push-branch**: Override branch to push to, defaults to the same branch the action is currently running on.
* **push-remote**: Override remote to push to, defaults to the same repo the action is currently running on. Must be in GIT URL format, example below.
* **commit-message**: Specify commit message, defaults to `autocommit`.
* **force-add**: Force add files, useful for adding ignored files. Defaults to `false`.
* **force-push**: Force git push, defaults to `false`.
* **rebase**: Pull and rebase before commiting. Useful when using commit inside matrix. Defaults to `false`
* **files**: Specific files to add. Uses the same format as `git add`. Defaults to all files.
* **email**: Committer email. Default is `${name}@users.noreply.github.com`
* **name**: Committer name. Default is name of the person or app that initiated the workflow.


### Example

```yaml
Expand All @@ -27,6 +41,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
push-branch: 'master'
push-remote: https://github.com/some-org/some-repo.git
commit-message: 'publish'
force-add: 'true'
files: a.txt b.txt c.txt dirA/ dirB/ dirC/a.txt
Expand Down Expand Up @@ -68,5 +83,6 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
push-branch: master
commit-message: '${{ matrix.node-version }} adds auto-generated benchmarks and bar graph'
files: a.text build/
rebase: 'true' # pull and rebase before commit
```
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
push-branch:
description: 'Override branch to push to'
required: false
push-remote:
description: 'Override remote to push to'
required: false
commit-message:
description: 'Specify commit message'
required: false
Expand Down
3 changes: 3 additions & 0 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def run():
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:])
remote = local.env.get('INPUT_PUSH-REMOTE')
rebase = local.env.get('INPUT_REBASE', 'false')
files = local.env.get('INPUT_FILES', '')
email = local.env.get('INPUT_EMAIL', f'{github_actor}@users.noreply.github.com')
Expand All @@ -36,6 +37,8 @@ def run():
debug(f'username:{github_actor}, branch:{branch}, commit message:{commit_message}')
with open(netrc_path) as f:
debug(f.read())
if remote:
debug(git(['remote', 'set-url', 'origin', remote]))
add_args = ['add']
if force_add == 'true':
add_args.append('-f')
Expand Down