Feature: Add File Pattern Input (#13)

Feature: Add File Pattern Input
This commit is contained in:
Stefan Zweifel 2019-10-26 16:37:31 +02:00 committed by GitHub
commit 134234c02d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 14 deletions

View File

@ -4,7 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.1.0...HEAD)
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.2.0...HEAD)
## [v2.2.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.1.0...v2.2.0) - 2019-10-26
### Added
- Add new `file_pattern`-argument. Allows users to define which files should be added in the commit. [#13](https://github.com/stefanzweifel/git-auto-commit-action/pull/13)
## [v2.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.0.0...v2.1.0) - 2019-09-20

View File

@ -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 }}
```
@ -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.
@ -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.
## 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).

View File

@ -10,6 +10,10 @@ inputs:
branch:
description: Branch where changes should be pushed too
required: true
file_pattern:
description: File pattern used for "git add"
required: false
default: '.'
runs:
using: 'docker'

View File

@ -30,7 +30,13 @@ then
# Switch to branch from current Workflow run
git checkout $INPUT_BRANCH
if [ -z ${INPUT_FILE_PATTERN+x} ];
then
git add .
else
echo "INPUT_FILE_PATTERN value: $INPUT_FILE_PATTERN";
git add $INPUT_FILE_PATTERN
fi
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>"