Compare commits

...

44 Commits

Author SHA1 Message Date
Stefan Zweifel
6d7a33192e Release v2.5.0 2019-12-18 11:59:49 +01:00
Stefan Zweifel
d625ec8b28 Update Description of inputs 2019-12-18 11:58:17 +01:00
Stefan Zweifel
e870f94840 Update Changelog 2019-12-18 11:57:16 +01:00
Stefan Zweifel
4a6ffd0603 Merge pull request #24 from stefanzweifel/extract-logic-to-lib
Extract methods into lib.sh / Add shellcheck workflow
2019-12-16 14:57:24 +01:00
Stefan Zweifel
dcfe3115ff WIP 2019-12-12 21:40:03 +01:00
Stefan Zweifel
3f6e990b1e Update lib.sh 2019-12-12 21:14:38 +01:00
Stefan Zweifel
560cf49647 Update Workflow 2019-12-12 21:10:29 +01:00
Stefan Zweifel
c62363dd62 Add Workflow to run Shellcheck 2019-12-12 21:05:01 +01:00
Stefan Zweifel
7c85ce3dee Update path to lib.sh 2019-12-12 20:46:16 +01:00
Stefan Zweifel
8bb153baaa Update Dockerfile 2019-12-12 20:45:42 +01:00
Stefan Zweifel
68035425ff Update Path 2019-12-12 20:44:41 +01:00
Stefan Zweifel
3273c330f8 Fix path 2019-12-12 20:42:47 +01:00
Stefan Zweifel
4280601118 Create lib.sh and update entrypoint.sh 2019-12-12 20:41:00 +01:00
Stefan Zweifel
3c148f8a94 Merge pull request #22 from yelizariev/custom-repo-path
Add "repository" option for custom repository path
2019-12-10 20:20:25 +01:00
Ivan Yelizariev
d3ceacae7d Add "repository" option for custom repository path 2019-12-10 17:20:25 +05:00
Stefan Zweifel
d338d7dd00 Update README to latest version 2019-11-30 19:42:53 +01:00
Stefan Zweifel
f7e2c0f118 Release v2.4.0 2019-11-30 19:40:57 +01:00
Stefan Zweifel
8db04fa14f Merge pull request #21 from jkaan/feature/add-support-for-lfs
Install Git-LFS while building Dockerfile
2019-11-30 19:37:41 +01:00
Joey Kaan
44a415d3cb Install Git-LFS while building Dockerfile 2019-11-30 13:05:28 +01:00
Stefan Zweifel
af9e1689a5 Update Changelog 2019-11-27 20:07:24 +01:00
Stefan Zweifel
2b22ba6212 Merge pull request #19 from localheinz/fix/untracked
Fix: Use 'git status -s' to check for untracked/modified files
2019-11-27 20:03:09 +01:00
Andreas Möller
b1b8ae8b5c Fix: Use 'git status -s' to check for untracked/modified files 2019-11-27 11:24:27 +01:00
Stefan Zweifel
fb3de05451 Revert "Fix: Add files that are not tracked yet"
This reverts commit 65d8bdf167.
2019-11-24 12:21:42 +01:00
Stefan Zweifel
284d0b78f0 Fix: Add files that are not tracked yet (#17)
Fix: Add files that are not tracked yet
2019-11-22 13:00:18 +01:00
Stefan Zweifel
188fc2bd58 Delete foo 2019-11-22 12:59:27 +01:00
Andreas Möller
65d8bdf167 Fix: Add files that are not tracked yet 2019-11-22 11:55:58 +01:00
Stefan Zweifel
40255153c4 Fix Link in README 2019-11-04 20:09:04 +01:00
Stefan Zweifel
0ef5bf58dc Tag v2.3.0 2019-11-04 20:07:50 +01:00
Stefan Zweifel
e924b16154 Merge pull request #15 from gomorizsolt/issue-14_support-custom-git-params
Support custom git params.
Fixes #14
2019-11-04 20:04:09 +01:00
Gömöri Zsolt
2fb839c669 Remove is_defined() 2019-11-01 11:11:19 +01:00
Gömöri Zsolt
908446c002 Use :+ to avoid empty string 2019-11-01 11:03:23 +01:00
Gömöri Zsolt
2d23a29775 Use one-line if statement 2019-11-01 10:53:56 +01:00
Gömöri Zsolt
bdc88aff2c Re-add is_defined() to eliminate empty string in git commit 2019-11-01 10:44:09 +01:00
Gömöri Zsolt
ddcd35eaa8 Remove is_defined() approach 2019-11-01 10:19:20 +01:00
Gömöri Zsolt
760c9be2dc Define default value for file_pattern 2019-11-01 10:15:22 +01:00
Gömöri Zsolt
69d0349561 Log input params beforehand 2019-11-01 10:10:52 +01:00
Gömöri Zsolt
eecee2898e Follow GH Action's naming restrictions 2019-11-01 10:04:42 +01:00
Gömöri Zsolt
3889fd6a6c Add args entry to actions.yml 2019-11-01 09:51:54 +01:00
Gömöri Zsolt
1ad5315ba7 Fix log statement 2019-11-01 09:51:19 +01:00
gomorizsolt
fa043bd474 Remove junk code 2019-10-31 15:13:27 +01:00
gomorizsolt
af33cfbb5c Replace get_value with is_defined altogether 2019-10-31 14:49:38 +01:00
gomorizsolt
677efa2969 Remove blank line 2019-10-31 11:25:08 +01:00
gomorizsolt
b6dcf94303 Add is_defined and get_value to improve on code's reusability 2019-10-31 11:18:48 +01:00
gomorizsolt
a65a3a47cd Support commit options, update README.md accordingly 2019-10-31 09:02:56 +01:00
7 changed files with 123 additions and 39 deletions

12
.github/workflows/shellcheck.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: Shellcheck
on: push
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: shellcheck
uses: ludeeus/action-shellcheck@0.1.0

View File

@@ -4,13 +4,38 @@ 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.2.0...HEAD)
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.5.0...HEAD)
> TBD
## [v2.5.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.4.0...v2.5.0) - 2019-12-18
### Added
- Add new `repository`-argument [#22](https://github.com/stefanzweifel/git-auto-commit-action/pull/22)
### Changed
- Extract logic of the Action into methods and into a separate file [#24](https://github.com/stefanzweifel/git-auto-commit-action/pull/24)
## [v2.4.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.3.0...v2.4.0) - 2019-11-30
### Added
- Commit untracked files [#19](https://github.com/stefanzweifel/git-auto-commit-action/pull/19) (fixes [#16](https://github.com/stefanzweifel/git-auto-commit-action/issues/16))
- Add support for Git-LFS [#21](https://github.com/stefanzweifel/git-auto-commit-action/pull/21) (fixes [#20](https://github.com/stefanzweifel/git-auto-commit-action/issues/20))
## [v2.3.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.2.0...v2.3.0) - 2019-11-04
### Added
- Add a new `commit_option`-argument. Allows users to define additional commit options for the `git-commit` command. [#14](https://github.com/stefanzweifel/git-auto-commit-action/pull/15)
## [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
### Added

View File

@@ -9,6 +9,9 @@ LABEL "repository"="http://github.com/stefanzweifel/git-auto-commit-action"
LABEL "homepage"="http://github.com/stefanzweifel/git-auto-commit-action"
LABEL "maintainer"="Stefan Zweifel <hello@stefanzweifel.io>"
RUN apk add git-lfs
COPY lib.sh /lib.sh
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["sh", "/entrypoint.sh"]

View File

@@ -13,13 +13,20 @@ This Action has been inspired and adapted from the [auto-commit](https://github.
Add the following step at the end of your job.
```yaml
- uses: stefanzweifel/git-auto-commit-action@v2.2.0
- uses: stefanzweifel/git-auto-commit-action@v2.5.0
with:
commit_message: Apply automatic changes
branch: ${{ github.head_ref }}
# Optional git params
commit_options: '--no-verify --signoff'
# Optional glob pattern of files which should be added to the commit
file_pattern: src/\*.js
# Optional repository path
repository: .
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
@@ -59,7 +66,7 @@ jobs:
uses: docker://oskarstark/php-cs-fixer-ga
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v2.2.0
uses: stefanzweifel/git-auto-commit-action@v2.5.0
with:
commit_message: Apply php-cs-fixer changes
branch: ${{ github.head_ref }}
@@ -71,7 +78,7 @@ jobs:
### Inputs
Checkout [`actions.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/actions.yml) for a full list of supported inputs.
Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/action.yml) for a full list of supported inputs.
## Versioning

View File

@@ -7,17 +7,30 @@ inputs:
commit_message:
description: Commit message
required: true
commit_options:
description: Commit options (eg. --no-verify)
required: false
branch:
description: Branch where changes should be pushed too
description: Branch name where changes should be pushed too
required: true
file_pattern:
description: File pattern used for "git add"
required: false
default: '.'
repository:
description: Path to git repository
required: false
default: '.'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.commit_message }}
- ${{ inputs.commit_options }}
- ${{ inputs.branch }}
- ${{ inputs.file_pattern }}
- ${{ inputs.repository }}
branding:
icon: 'git-commit'

View File

@@ -1,46 +1,22 @@
#!/bin/sh
#!/bin/bash
set -eu
# Set up .netrc file with GitHub credentials
git_setup ( ) {
cat <<- EOF > $HOME/.netrc
machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
source /lib.sh
machine api.github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF
chmod 600 $HOME/.netrc
_switch_to_repository
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
}
if _git_is_dirty; then
_setup_git
# This section only runs if there have been file changes
echo "Checking for uncommitted changes in the git working tree."
if ! git diff --quiet
then
git_setup
_switch_to_branch
echo "INPUT_BRANCH value: $INPUT_BRANCH";
_add_files
# Switch to branch from current Workflow run
git checkout $INPUT_BRANCH
_local_commit
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>"
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
_push_to_github
else
echo "Working tree clean. Nothing to commit."
fi

48
lib.sh Normal file
View File

@@ -0,0 +1,48 @@
#!/bin/bash
_switch_to_repository() {
echo "INPUT_REPOSITORY value: $INPUT_REPOSITORY";
cd $INPUT_REPOSITORY
}
_git_is_dirty() {
[[ -n "$(git status -s)" ]]
}
# Set up .netrc file with GitHub credentials
_setup_git ( ) {
cat <<- EOF > $HOME/.netrc
machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
machine api.github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF
chmod 600 $HOME/.netrc
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
}
_switch_to_branch() {
echo "INPUT_BRANCH value: $INPUT_BRANCH";
# Switch to branch from current Workflow run
git checkout $INPUT_BRANCH
}
_add_files() {
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}"
git add "${INPUT_FILE_PATTERN}"
}
_local_commit() {
echo "INPUT_COMMIT_OPTIONS: ${INPUT_COMMIT_OPTIONS}"
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
}
_push_to_github() {
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
}