mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-08-02 00:16:10 +08:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6d7a33192e | ||
|
d625ec8b28 | ||
|
e870f94840 | ||
|
4a6ffd0603 | ||
|
dcfe3115ff | ||
|
3f6e990b1e | ||
|
560cf49647 | ||
|
c62363dd62 | ||
|
7c85ce3dee | ||
|
8bb153baaa | ||
|
68035425ff | ||
|
3273c330f8 | ||
|
4280601118 | ||
|
3c148f8a94 | ||
|
d3ceacae7d | ||
|
d338d7dd00 |
12
.github/workflows/shellcheck.yml
vendored
Normal file
12
.github/workflows/shellcheck.yml
vendored
Normal 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
|
16
CHANGELOG.md
16
CHANGELOG.md
@@ -4,7 +4,18 @@ 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.4.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
|
||||
|
||||
@@ -12,16 +23,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- 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
|
||||
|
@@ -11,6 +11,7 @@ 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"]
|
||||
|
@@ -13,7 +13,7 @@ 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.3.0
|
||||
- uses: stefanzweifel/git-auto-commit-action@v2.5.0
|
||||
with:
|
||||
commit_message: Apply automatic changes
|
||||
branch: ${{ github.head_ref }}
|
||||
@@ -23,6 +23,10 @@ Add the following step at the end of your job.
|
||||
|
||||
# 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 }}
|
||||
```
|
||||
@@ -62,7 +66,7 @@ jobs:
|
||||
uses: docker://oskarstark/php-cs-fixer-ga
|
||||
|
||||
- name: Commit changed files
|
||||
uses: stefanzweifel/git-auto-commit-action@v2.3.0
|
||||
uses: stefanzweifel/git-auto-commit-action@v2.5.0
|
||||
with:
|
||||
commit_message: Apply php-cs-fixer changes
|
||||
branch: ${{ github.head_ref }}
|
||||
|
@@ -8,15 +8,19 @@ inputs:
|
||||
description: Commit message
|
||||
required: true
|
||||
commit_options:
|
||||
description: 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'
|
||||
@@ -26,6 +30,7 @@ runs:
|
||||
- ${{ inputs.commit_options }}
|
||||
- ${{ inputs.branch }}
|
||||
- ${{ inputs.file_pattern }}
|
||||
- ${{ inputs.repository }}
|
||||
|
||||
branding:
|
||||
icon: 'git-commit'
|
||||
|
@@ -1,44 +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
|
||||
|
||||
# This section only runs if there have been file changes
|
||||
echo "Checking for uncommitted changes in the git working tree."
|
||||
if [[ -n "$(git status -s)" ]]
|
||||
then
|
||||
git_setup
|
||||
_setup_git
|
||||
|
||||
echo "INPUT_BRANCH value: $INPUT_BRANCH";
|
||||
_switch_to_branch
|
||||
|
||||
# Switch to branch from current Workflow run
|
||||
git checkout $INPUT_BRANCH
|
||||
_add_files
|
||||
|
||||
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}"
|
||||
_local_commit
|
||||
|
||||
git add "${INPUT_FILE_PATTERN}"
|
||||
|
||||
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"}
|
||||
|
||||
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
48
lib.sh
Normal 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"
|
||||
}
|
Reference in New Issue
Block a user