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

Feature: Add File Pattern Input #13

Merged
merged 7 commits into from
Oct 26, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Add the following step at the end of your job.
with:
commit_message: Apply automatic changes
branch: ${{ github.head_ref }}

# Optional glob pattern of files which should be added to the commit
file_pattern: src/\*.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
Expand All @@ -27,18 +30,6 @@ The Action will only commit files back, if changes are available. The resulting

It is recommended to use this Action in Workflows which listen to the `pull_request` event. If you want to use the Action on other events, you have to hardcode the value for `branch` as `github.head_ref` is only available in Pull Requests.


### Inputs

The following inputs are required

- `commit_message`: The commit message used when changes are available
- `branch`: Branch name where changes should be pushed to

### Environment Variables

The `GITHUB_TOKEN` secret is required. It is automatically available in your repository. You have to add it to the configuration though.

## Example Usage

This Action will only work, if the job in your workflow changes project files.
Expand Down Expand Up @@ -72,11 +63,16 @@ jobs:
with:
commit_message: Apply php-cs-fixer changes
branch: ${{ github.head_ref }}
file_pattern: src/\*.php
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

```

### Inputs

Checkout [`actions.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/actions.yml) for a full list of supported inputs.
stefanzweifel marked this conversation as resolved.
Show resolved Hide resolved

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/stefanzweifel/git-auto-commit-action/tags).
Expand Down
3 changes: 3 additions & 0 deletions actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
branch:
description: Branch where changes should be pushed too
required: true
file_pattern:
description: File pattern used for "git add"
default: '.'
stefanzweifel marked this conversation as resolved.
Show resolved Hide resolved

runs:
using: 'docker'
Expand Down
7 changes: 6 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ then
# Switch to branch from current Workflow run
git checkout $INPUT_BRANCH

git add .
if [ -z ${INPUT_FILE_PATTERN+x} ];
stefanzweifel marked this conversation as resolved.
Show resolved Hide resolved
then
git add .
else
git add $INPUT_FILE_PATTERN
fi

git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <[email protected]>"

Expand Down