mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-07-31 15:26:10 +08:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0b007fbd11 | ||
|
7106b2184a | ||
|
f166130208 | ||
|
021a6363fa | ||
|
38864a638f | ||
|
393fea59ef | ||
|
0049e3fa40 | ||
|
f6f7a9c351 |
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
2
.github/workflows/git-auto-commit.yml
vendored
2
.github/workflows/git-auto-commit.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Use git-auto-commit-action
|
||||
id: "auto-commit-action"
|
||||
|
4
.github/workflows/linter.yml
vendored
4
.github/workflows/linter.yml
vendored
@@ -9,10 +9,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Lint Code Base
|
||||
uses: github/super-linter@v3
|
||||
uses: github/super-linter@v4
|
||||
env:
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
VALIDATE_MARKDOWN: false
|
||||
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install testing dependencies
|
||||
run: yarn install
|
||||
|
2
.github/workflows/update-changelog.yaml
vendored
2
.github/workflows/update-changelog.yaml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: master
|
||||
|
||||
|
14
CHANGELOG.md
14
CHANGELOG.md
@@ -5,10 +5,22 @@ 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/v4.15.1...HEAD)
|
||||
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.3...HEAD)
|
||||
|
||||
> TBD
|
||||
|
||||
## [v4.15.3](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.2...v4.15.3) - 2022-10-26
|
||||
|
||||
### Changed
|
||||
|
||||
- Use deprecated set-output syntax if GITHUB_OUTPUT environment is not available ([#255](https://github.com/stefanzweifel/git-auto-commit-action/pull/255)) [@stefanzweifel](https://github.com/@stefanzweifel)
|
||||
|
||||
## [v4.15.2](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.1...v4.15.2) - 2022-10-22
|
||||
|
||||
### Changed
|
||||
|
||||
- Replace set-output usage with GITHUB_OUTPUT ([#252](https://github.com/stefanzweifel/git-auto-commit-action/pull/252)) [@amonshiz](https://github.com/amonshiz)
|
||||
|
||||
## [v4.15.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.0...v4.15.1) - 2022-10-10
|
||||
|
||||
### Fixed
|
||||
|
@@ -70,6 +70,9 @@ inputs:
|
||||
create_branch:
|
||||
description: Create new branch with the name of `branch`-input in local and remote repository, if it doesn't exist yet.
|
||||
default: false
|
||||
internal_git_binary:
|
||||
description: Internal use only! Path to git binary used to check if git is available. (Don't change this!)
|
||||
default: git
|
||||
|
||||
outputs:
|
||||
changes_detected:
|
||||
|
@@ -7,11 +7,19 @@ if "$INPUT_DISABLE_GLOBBING"; then
|
||||
fi
|
||||
|
||||
_main() {
|
||||
_check_if_git_is_available
|
||||
|
||||
_switch_to_repository
|
||||
|
||||
if _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then
|
||||
|
||||
echo "changes_detected=true" >> $GITHUB_OUTPUT;
|
||||
# Check if $GITHUB_OUTPUT is available
|
||||
# (Feature detection will be removed in late December 2022)
|
||||
if [ -z ${GITHUB_OUTPUT+x} ]; then
|
||||
echo "::set-output name=changes_detected::true";
|
||||
else
|
||||
echo "changes_detected=true" >> $GITHUB_OUTPUT;
|
||||
fi
|
||||
|
||||
_switch_to_branch
|
||||
|
||||
@@ -24,12 +32,26 @@ _main() {
|
||||
_push_to_github
|
||||
else
|
||||
|
||||
echo "changes_detected=false" >> $GITHUB_OUTPUT;
|
||||
# Check if $GITHUB_OUTPUT is available
|
||||
# (Feature detection will be removed in late December 2022)
|
||||
if [ -z ${GITHUB_OUTPUT+x} ]; then
|
||||
echo "::set-output name=changes_detected::false";
|
||||
else
|
||||
echo "changes_detected=false" >> $GITHUB_OUTPUT;
|
||||
fi
|
||||
|
||||
echo "Working tree clean. Nothing to commit.";
|
||||
fi
|
||||
}
|
||||
|
||||
_check_if_git_is_available() {
|
||||
if hash -- "$INPUT_INTERNAL_GIT_BINARY" 2> /dev/null; then
|
||||
echo "::debug::git binary found.";
|
||||
else
|
||||
echo "::error ::git-auto-commit could not find git binary. Please make sure git is available."
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
_switch_to_repository() {
|
||||
echo "INPUT_REPOSITORY value: $INPUT_REPOSITORY";
|
||||
@@ -101,7 +123,14 @@ _local_commit() {
|
||||
--author="$INPUT_COMMIT_AUTHOR" \
|
||||
${INPUT_COMMIT_OPTIONS:+"${INPUT_COMMIT_OPTIONS_ARRAY[@]}"};
|
||||
|
||||
echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT;
|
||||
|
||||
# Check if $GITHUB_OUTPUT is available
|
||||
# (Feature detection will be removed in late December 2022)
|
||||
if [ -z ${GITHUB_OUTPUT+x} ]; then
|
||||
echo "::set-output name=commit_hash::$(git rev-parse HEAD)";
|
||||
else
|
||||
echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT;
|
||||
fi
|
||||
}
|
||||
|
||||
_tag_commit() {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"bats": "^1.1.0",
|
||||
"bats": "^1.8.2",
|
||||
"bats-assert": "ztombol/bats-assert",
|
||||
"bats-support": "ztombol/bats-support"
|
||||
},
|
||||
|
@@ -37,6 +37,7 @@ setup() {
|
||||
export INPUT_SKIP_CHECKOUT=false
|
||||
export INPUT_DISABLE_GLOBBING=false
|
||||
export INPUT_CREATE_BRANCH=false
|
||||
export INPUT_INTERNAL_GIT_BINARY=git
|
||||
|
||||
# Set GitHub environment variables used by the GitHub Action
|
||||
temp_github_output_file=$(mktemp -t github_output_test.XXXXX)
|
||||
@@ -57,7 +58,12 @@ teardown() {
|
||||
rm -rf "${FAKE_LOCAL_REPOSITORY}"
|
||||
rm -rf "${FAKE_REMOTE}"
|
||||
rm -rf "${FAKE_TEMP_LOCAL_REPOSITORY}"
|
||||
rm "${GITHUB_OUTPUT}"
|
||||
|
||||
if [ -z ${GITHUB_OUTPUT+x} ]; then
|
||||
echo "GITHUB_OUTPUT is not set"
|
||||
else
|
||||
rm "${GITHUB_OUTPUT}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Create a fake remote repository which tests can push against
|
||||
@@ -997,3 +1003,53 @@ cat_github_output() {
|
||||
refute_line --partial "new-file-2.txt"
|
||||
refute_line --partial "new-file-3.txt"
|
||||
}
|
||||
|
||||
|
||||
@test "It uses old set-output syntax if GITHUB_OUTPUT environment is not available when changes are committed" {
|
||||
unset GITHUB_OUTPUT
|
||||
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "INPUT_BRANCH value: ${FAKE_DEFAULT_BRANCH}"
|
||||
assert_line "INPUT_FILE_PATTERN: ."
|
||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||
assert_line "::debug::Apply commit options "
|
||||
assert_line "INPUT_TAGGING_MESSAGE: "
|
||||
assert_line "No tagging message supplied. No tag will be added."
|
||||
assert_line "INPUT_PUSH_OPTIONS: "
|
||||
assert_line "::debug::Apply push options "
|
||||
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||
|
||||
assert_line "::set-output name=changes_detected::true"
|
||||
assert_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
||||
}
|
||||
|
||||
@test "It uses old set-output syntax if GITHUB_OUTPUT environment is not available when no changes have been detected" {
|
||||
unset GITHUB_OUTPUT
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "Working tree clean. Nothing to commit."
|
||||
|
||||
assert_line "::set-output name=changes_detected::false"
|
||||
refute_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
||||
}
|
||||
|
||||
@test "It fails hard if git is not available" {
|
||||
INPUT_INTERNAL_GIT_BINARY=binary-does-not-exist
|
||||
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_failure;
|
||||
assert_line "::error ::git-auto-commit could not find git binary. Please make sure git is available."
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ bats-support@ztombol/bats-support:
|
||||
version "0.3.0"
|
||||
resolved "https://codeload.github.com/ztombol/bats-support/tar.gz/004e707638eedd62e0481e8cdc9223ad471f12ee"
|
||||
|
||||
bats@^1.1.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/bats/-/bats-1.7.0.tgz#caae958b1d211eda6b1322ac7792515de40165a2"
|
||||
integrity sha512-pt5zjJQUB4+JI8Si+z/IAWc8yhMyhdZs6IXMCKgzF768dUIyW5xyBstWtDI5uGSa80v7UQOhh+w0GA4p4+01Bg==
|
||||
bats@^1.8.2:
|
||||
version "1.8.2"
|
||||
resolved "https://registry.yarnpkg.com/bats/-/bats-1.8.2.tgz#bdbaa7690a18f04291b35144a8ce5435cffb8dc5"
|
||||
integrity sha512-KLUIaPYuIMjqui8MbZmK84+CiwhjFVFAhFy5PXP0prLbkovc5faVzc+Qaowbz76F97zP573JrF31ODFAH7vzhg==
|
||||
|
Reference in New Issue
Block a user