From 925bbcaef30b3bb8918437735cff69dffcc3de4a Mon Sep 17 00:00:00 2001 From: stefanzweifel Date: Fri, 2 Dec 2022 06:50:39 +0000 Subject: [PATCH 01/62] Update CHANGELOG --- CHANGELOG.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8238615a..3658910a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,21 @@ 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.4...HEAD) +## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.16.0...HEAD) > TBD +## [v4.16.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.4...v4.16.0) - 2022-12-02 + +### Changed + +- Don't commit files when only LF/CRLF changes ([#265](https://github.com/stefanzweifel/git-auto-commit-action/pull/265)) [@ZeroRin](https://github.com/@ZeroRin) +- Update default email address of github-actions[bot] ([#264](https://github.com/stefanzweifel/git-auto-commit-action/pull/264)) [@Teko012](https://github.com/@Teko012) + +### Fixed + +- Fix link and text for workflow limitation ([#263](https://github.com/stefanzweifel/git-auto-commit-action/pull/263)) [@Teko012](https://github.com/@Teko012) + ## [v4.15.4](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.3...v4.15.4) - 2022-11-05 ### Fixed From aeb1802648f7edfed48c9a530eea1a74d58dc2f4 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Thu, 22 Dec 2022 19:45:17 +0100 Subject: [PATCH 02/62] Add _log and _set_github_output functions (#273) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add _set_github_output function * Use _set_github_output in Action * Add _log function * Use _log in Action and fix Test Cases * Update wording in log messages * Update note about removal of old output syntax Logic is now encapuslated in a single function. I don’t mind keeping it around until spring / June 2023 --- entrypoint.sh | 79 +++++++++++++++++--------------------- tests/git-auto-commit.bats | 6 +-- 2 files changed, 39 insertions(+), 46 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 3c858317..a964e7f8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,6 +6,26 @@ if "$INPUT_DISABLE_GLOBBING"; then set -o noglob; fi +_set_github_output() { + local name=${1} + local value=${2} + + # Check if $GITHUB_OUTPUT is available + # (Feature detection will be removed in spring 2023) + if [ -z ${GITHUB_OUTPUT+x} ]; then + echo "::set-output name=$name::$value"; + else + echo "$name=$value" >> $GITHUB_OUTPUT; + fi +} + +_log() { + local level=${1} + local message=${2} + + echo "::$level::$message"; +} + _main() { _check_if_git_is_available @@ -13,13 +33,7 @@ _main() { if _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then - # 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 + _set_github_output "changes_detected" "true" _switch_to_branch @@ -36,26 +50,12 @@ _main() { _push_to_github else - - # 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 + _set_github_output "changes_detected" "false" echo "Working tree clean. Nothing to commit."; fi else - - # 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 + _set_github_output "changes_detected" "false" echo "Working tree clean. Nothing to commit."; fi @@ -63,9 +63,9 @@ _main() { _check_if_git_is_available() { if hash -- "$INPUT_INTERNAL_GIT_BINARY" 2> /dev/null; then - echo "::debug::git binary found."; + _log "debug" "git binary found."; else - echo "::error ::git-auto-commit could not find git binary. Please make sure git is available." + _log "error" "git-auto-commit could not find git binary. Please make sure git is available." exit 1; fi } @@ -77,7 +77,7 @@ _switch_to_repository() { _git_is_dirty() { echo "INPUT_STATUS_OPTIONS: ${INPUT_STATUS_OPTIONS}"; - echo "::debug::Apply status options ${INPUT_STATUS_OPTIONS}"; + _log "debug" "Apply status options ${INPUT_STATUS_OPTIONS}"; echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}"; read -r -a INPUT_FILE_PATTERN_EXPANDED <<< "$INPUT_FILE_PATTERN"; @@ -91,14 +91,14 @@ _switch_to_branch() { # Fetch remote to make sure that repo can be switched to the right branch. if "$INPUT_SKIP_FETCH"; then - echo "::debug::git-fetch has not been executed"; + _log "debug" "git-fetch will not be executed."; else git fetch --depth=1; fi # If `skip_checkout`-input is true, skip the entire checkout step. if "$INPUT_SKIP_CHECKOUT"; then - echo "::debug::git-checkout has not been executed"; + _log "debug" "git-checkout will not be executed."; else # Create new local branch if `create_branch`-input is true if "$INPUT_CREATE_BRANCH"; then @@ -114,7 +114,7 @@ _switch_to_branch() { _add_files() { echo "INPUT_ADD_OPTIONS: ${INPUT_ADD_OPTIONS}"; - echo "::debug::Apply add options ${INPUT_ADD_OPTIONS}"; + _log "debug" "Apply add options ${INPUT_ADD_OPTIONS}"; echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}"; read -r -a INPUT_FILE_PATTERN_EXPANDED <<< "$INPUT_FILE_PATTERN"; @@ -125,7 +125,7 @@ _add_files() { _local_commit() { echo "INPUT_COMMIT_OPTIONS: ${INPUT_COMMIT_OPTIONS}"; - echo "::debug::Apply commit options ${INPUT_COMMIT_OPTIONS}"; + _log "debug" "Apply commit options ${INPUT_COMMIT_OPTIONS}"; # shellcheck disable=SC2206 INPUT_COMMIT_OPTIONS_ARRAY=( $INPUT_COMMIT_OPTIONS ); @@ -140,14 +140,7 @@ _local_commit() { --author="$INPUT_COMMIT_AUTHOR" \ ${INPUT_COMMIT_OPTIONS:+"${INPUT_COMMIT_OPTIONS_ARRAY[@]}"}; - - # 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 + _set_github_output "commit_hash" $(git rev-parse HEAD) } _tag_commit() { @@ -155,7 +148,7 @@ _tag_commit() { if [ -n "$INPUT_TAGGING_MESSAGE" ] then - echo "::debug::Create tag $INPUT_TAGGING_MESSAGE"; + _log "debug" "Create tag $INPUT_TAGGING_MESSAGE"; git -c user.name="$INPUT_COMMIT_USER_NAME" -c user.email="$INPUT_COMMIT_USER_EMAIL" tag -a "$INPUT_TAGGING_MESSAGE" -m "$INPUT_TAGGING_MESSAGE"; else echo "No tagging message supplied. No tag will be added."; @@ -165,7 +158,7 @@ _tag_commit() { _push_to_github() { echo "INPUT_PUSH_OPTIONS: ${INPUT_PUSH_OPTIONS}"; - echo "::debug::Apply push options ${INPUT_PUSH_OPTIONS}"; + _log "debug" "Apply push options ${INPUT_PUSH_OPTIONS}"; # shellcheck disable=SC2206 INPUT_PUSH_OPTIONS_ARRAY=( $INPUT_PUSH_OPTIONS ); @@ -175,15 +168,15 @@ _push_to_github() { # Only add `--tags` option, if `$INPUT_TAGGING_MESSAGE` is set if [ -n "$INPUT_TAGGING_MESSAGE" ] then - echo "::debug::git push origin --tags"; + _log "debug" "git push origin --tags"; git push origin --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"}; else - echo "::debug::git push origin"; + _log "debug" "git push origin"; git push origin ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"}; fi else - echo "::debug::Push commit to remote branch $INPUT_BRANCH"; + _log "debug" "Push commit to remote branch $INPUT_BRANCH"; git push --set-upstream origin "HEAD:$INPUT_BRANCH" --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"}; fi } diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index ead4db75..9ca1014e 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -417,7 +417,7 @@ cat_github_output() { assert_success - assert_line "::debug::git-fetch has not been executed" + assert_line "::debug::git-fetch will not be executed." } @test "If SKIP_CHECKOUT is true git-checkout will not be called" { @@ -430,7 +430,7 @@ cat_github_output() { assert_success - assert_line "::debug::git-checkout has not been executed" + assert_line "::debug::git-checkout will not be executed." } @test "It pushes generated commit and tag to remote and actually updates the commit shas" { @@ -1090,5 +1090,5 @@ cat_github_output() { run git_auto_commit assert_failure; - assert_line "::error ::git-auto-commit could not find git binary. Please make sure git is available." + assert_line "::error::git-auto-commit could not find git binary. Please make sure git is available." } From 86fb2e11b29e925e8f69e11ea53599e56383379e Mon Sep 17 00:00:00 2001 From: cong Date: Tue, 3 Jan 2023 15:17:32 +0800 Subject: [PATCH 03/62] Fix git-auto-commit.yml (#277) --- .github/workflows/git-auto-commit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/git-auto-commit.yml b/.github/workflows/git-auto-commit.yml index 038521e4..0334115f 100644 --- a/.github/workflows/git-auto-commit.yml +++ b/.github/workflows/git-auto-commit.yml @@ -18,9 +18,9 @@ jobs: uses: ./ - name: "no changes detected" - if: steps.auto-commit-action.outputs.changes_detected == false + if: steps.auto-commit-action.outputs.changes_detected == 'false' run: "echo \"No changes detected\"" - name: "changes detected" - if: steps.auto-commit-action.outputs.changes_detected == true + if: steps.auto-commit-action.outputs.changes_detected == 'true' run: "echo \"Changes detected\"" From fe00d258677e45d1f05473557e57bdfe865370fc Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 7 Jan 2023 12:06:10 +0100 Subject: [PATCH 04/62] Add test for multi-line commit messages --- tests/git-auto-commit.bats | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index 9ca1014e..179a5c7b 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -1092,3 +1092,23 @@ cat_github_output() { assert_failure; assert_line "::error::git-auto-commit could not find git binary. Please make sure git is available." } + +@test "It creates multi-line commit messages" { + touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt + + COMMIT_MESSAGE=$(cat <<-END + this commit message + has multiple lines +END +) + + INPUT_COMMIT_MESSAGE=$COMMIT_MESSAGE + + run git_auto_commit + + assert_success + + # Assert last commit was signed off + run git log -n 1 + assert_output --partial $COMMIT_MESSAGE +} From 3663a6fa3ebeb37c44d95a85b93c3d3cc7083b69 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 14 Jan 2023 18:05:16 +0100 Subject: [PATCH 05/62] Update README.md --- README.md | 89 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index b2497660..7ac5232b 100644 --- a/README.md +++ b/README.md @@ -198,17 +198,61 @@ If you work in an organization and don't want to create a PAT from your personal ### Change to file is not detected -Does your workflow change a file but "git-auto-commit" does not detect the change? Check the `.gitignore` that applies to the respective file. You might have accidentally marked the file to be ignored by git. +Does your workflow change a file, but "git-auto-commit" does not detect the change? Check the `.gitignore` that applies to the respective file. You might have accidentally marked the file to be ignored by git. ## Advanced Uses -
-Use in forks from public repositories +### Multiline Commit Messages + +If your commit message should span multiple lines, you have to create a separate step to generate the string. + +The example below can be used as a starting point to generate a multiline commit meesage. Learn more how multiline strings in GitHub Actions work in the [GitHub documentation](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings). + +```yaml + # Building a multiline commit message + # Adjust to your liking + - run: echo "Commit Message 1" >> commitmessage.txt + - run: echo "Commit Message 2" >> commitmessage.txt + - run: echo "Commit Message 3" >> commitmessage.txt + + # Create a multiline string to be used by the git-auto-commit Action + - name: Set commit message + id: commit_message_step + run: | + echo 'commit_message<> $GITHUB_OUTPUT + cat commitmessage.txt >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + # Quick and dirty step to get rid of the temporary file holding the commit message + - run: rm -rf commitmessage.txt + + - uses: stefanzweifel/git-auto-commit-action@v4 + id: commit + with: + commit_message: ${{ steps.commit_message_step.outputs.commit_message }} +``` + +### Signing Commits & Other Git Command Line Options + +Using command lines options needs to be done manually for each workflow which you require the option enabled. So for example signing commits requires you to import the gpg signature each and every time. The following list of actions are worth checking out if you need to automate these tasks regularly. + +- [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer)) + +### Push to forks from private repositories + +By default, GitHub Actions doesn't run Workflows on forks from private repositories. To enable Actions for **private** repositories enable "Run workflows from pull requests" in your repository settings. + +See [this announcement from GitHub](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/) or the [GitHub docs](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository#enabling-workflows-for-private-repository-forks) for details. -**☝️ Important Notice**: This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\ -If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch. ---- +### Use in forks from public repositories + +
+Expand to learn more + +> **Note** +> This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\ +> If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch. By default, this Action will not run on Pull Requests which have been opened by forks. (This is a limitation by GitHub, not by us.) However, there are a couple of ways to use this Actions in Workflows that should be triggered by forked repositories. @@ -295,37 +339,15 @@ For more information about running Actions on forks, see [this announcement from
-
-Push to forks from private repositories - -By default, GitHub Actions doesn't run Workflows on forks from private repositories. To enable Actions for **private** repositories enable "Run workflows from pull requests" in your repository settings. - -See [this announcement from GitHub](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/) or the [GitHub docs](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository#enabling-workflows-for-private-repository-forks) for details. - -
+### Using `--amend` and `--no-edit` as commit options
- - Signing Commits & Other Git Command Line Options - - -Using command lines options needs to be done manually for each workflow which you require the option enabled. So for example signing commits requires you to import the gpg signature each and every time. The following list of actions are worth checking out if you need to automate these tasks regularly. - -- [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer)) - -
- -
- - Using `--amend` and `--no-edit` as commit options - - - - +Expand to learn more If you would like to use this Action to create a commit using [`--amend`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend) and [`--no-edit`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-edit) you need to make some adjustments. -**☝️ Important Notice:** You should understand the implications of rewriting history if you amend a commit that has already been published. [See rebasing](https://git-scm.com/docs/git-rebase#_recovering_from_upstream_rebase) +> **Warning** +> You should understand the implications of rewriting history if you amend a commit that has already been published. [See rebasing](https://git-scm.com/docs/git-rebase#_recovering_from_upstream_rebase). First, you need to extract the previous commit message by using `git log -1 --pretty=%s`. Then you need to provide this last commit message to the Action through the `commit_message` input option. @@ -385,7 +407,8 @@ store the token as a secret in your repository and pass the new token to the [`a ``` You can learn more about Personal Access Token in the [GitHub documentation](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). -**Note:** If you're working in an organisation, and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens. +> **Note** +> If you're working in an organisation, and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens. If you go the "force pushes" route, you have to enable force pushes to a protected branch (See [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to use force push like this. From 3b94e3d0179a57791345521ad5d33f91396a25f6 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Fri, 20 Jan 2023 15:31:53 +0100 Subject: [PATCH 06/62] Update README.md Closes #281 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7ac5232b..451c9b6f 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,8 @@ See [this announcement from GitHub](https://github.blog/2020-08-03-github-action > **Note** > This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\ +> Ensure your contributors enable "Allow edits by maintainers" when opening a pull request. ([Learn more](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)) \ +> \ > If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch. By default, this Action will not run on Pull Requests which have been opened by forks. (This is a limitation by GitHub, not by us.) From 92b3981e0b7e212ae8de76e5c0ebbae9213d1db8 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 25 Jan 2023 19:57:43 +0100 Subject: [PATCH 07/62] Update Author Email Address --- CODE_OF_CONDUCT.md | 2 +- action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index ed87d512..9cd1debc 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at hello@stefanzweifel.io. All +reported by contacting the project team at stefan@stefanzweifel.dev. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/action.yml b/action.yml index afc4bf2b..5e67a1f7 100644 --- a/action.yml +++ b/action.yml @@ -1,7 +1,7 @@ name: Git Auto Commit description: 'Automatically commits files which have been changed during the workflow run and push changes back to remote repository.' -author: Stefan Zweifel +author: Stefan Zweifel inputs: commit_message: From 94d6bf9d2205442189681a51f429ab9143657007 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 11 Feb 2023 12:23:24 +0100 Subject: [PATCH 08/62] Add permissions block to Workflows --- .github/workflows/git-auto-commit.yml | 6 ++++++ .github/workflows/release-drafter.yml | 7 +++++++ .github/workflows/update-changelog.yaml | 6 ++++++ .github/workflows/versioning.yml | 7 +++++++ 4 files changed, 26 insertions(+) diff --git a/.github/workflows/git-auto-commit.yml b/.github/workflows/git-auto-commit.yml index 0334115f..bf9bbcdd 100644 --- a/.github/workflows/git-auto-commit.yml +++ b/.github/workflows/git-auto-commit.yml @@ -10,6 +10,12 @@ jobs: git-auto-commit: runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # updaetd CHANGELOG back to the repository. + # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ + contents: write + steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 17fdb961..152a5099 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -8,6 +8,13 @@ on: jobs: update_release_draft: runs-on: ubuntu-latest + + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # updaetd CHANGELOG back to the repository. + # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ + contents: write + steps: - uses: release-drafter/release-drafter@v5 env: diff --git a/.github/workflows/update-changelog.yaml b/.github/workflows/update-changelog.yaml index a5d65093..e8820886 100644 --- a/.github/workflows/update-changelog.yaml +++ b/.github/workflows/update-changelog.yaml @@ -8,6 +8,12 @@ jobs: update: runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # updaetd CHANGELOG back to the repository. + # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ + contents: write + steps: - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index ad052193..396eface 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -7,6 +7,13 @@ on: jobs: actions-tagger: runs-on: windows-latest + + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # updaetd CHANGELOG back to the repository. + # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ + contents: write + steps: - uses: Actions-R-Us/actions-tagger@latest env: From ccd4d054a57846a7f1c0199df66e8fb8a15d6872 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 11 Feb 2023 21:14:56 +0100 Subject: [PATCH 09/62] Fix Typo in Workflow comments --- .github/workflows/git-auto-commit.yml | 3 +-- .github/workflows/release-drafter.yml | 3 +-- .github/workflows/update-changelog.yaml | 2 +- .github/workflows/versioning.yml | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/git-auto-commit.yml b/.github/workflows/git-auto-commit.yml index bf9bbcdd..a217b1c8 100644 --- a/.github/workflows/git-auto-commit.yml +++ b/.github/workflows/git-auto-commit.yml @@ -11,8 +11,7 @@ jobs: runs-on: ubuntu-latest permissions: - # Give the default GITHUB_TOKEN write permission to commit and push the - # updaetd CHANGELOG back to the repository. + # Give the default GITHUB_TOKEN write permission. # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ contents: write diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 152a5099..6106be2d 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -10,8 +10,7 @@ jobs: runs-on: ubuntu-latest permissions: - # Give the default GITHUB_TOKEN write permission to commit and push the - # updaetd CHANGELOG back to the repository. + # Give the default GITHUB_TOKEN write permission. # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ contents: write diff --git a/.github/workflows/update-changelog.yaml b/.github/workflows/update-changelog.yaml index e8820886..02c4e667 100644 --- a/.github/workflows/update-changelog.yaml +++ b/.github/workflows/update-changelog.yaml @@ -10,7 +10,7 @@ jobs: permissions: # Give the default GITHUB_TOKEN write permission to commit and push the - # updaetd CHANGELOG back to the repository. + # updated CHANGELOG back to the repository. # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ contents: write diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index 396eface..04b1f87c 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -9,8 +9,7 @@ jobs: runs-on: windows-latest permissions: - # Give the default GITHUB_TOKEN write permission to commit and push the - # updaetd CHANGELOG back to the repository. + # Give the default GITHUB_TOKEN write permission. # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ contents: write From f0b35f0a731335dde1eadd3dc0c9eefb4c45054f Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 11 Feb 2023 21:29:07 +0100 Subject: [PATCH 10/62] Mention new permission requirements in usage docs Starting February 2nd 2023, GitHub changed the default permissions of the GITHUB_TOKEN to be read-only in all new repositories.[1] git-auto-commits needs `write`-permissions for the `contents`-key in order to work properly. This commits updates the usage section, to mention the need for the permission requirements. The examples have also been updated to reflect that change. [1]: https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/ --- README.md | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 451c9b6f..28bab232 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,42 @@ If you want to learn more how this Action works under the hood, check out [this ## Usage -Add the following step at the end of your job, after other steps that might add or change files. +Adding git-auto-commit to your Workflow only takes a couple lines of code. + +1. Set the `contents`-permission of the default GITHUB_TOKEN to `true`. (Required to push new commits to the repository) +2. Add the following step at the end of your job, after other steps that might add or change files. ```yaml - uses: stefanzweifel/git-auto-commit-action@v4 ``` -Note that the Action has to be used in a Job that runs on a UNIX system (e.g. `ubuntu-latest`). -If you don't use the default permission of the GITHUB_TOKEN, give the Job or Workflow at least the `contents: write` permission. +Your Workflow should look similar to this example. + +```yaml +name: Format + +on: push + +jobs: + format-code: + runs-on: ubuntu-latest + + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # updated CHANGELOG back to the repository. + contents: write + + steps: + - uses: actions/checkout@v3 + + # Other steps that change files in the repository + + # Commit all changed files back to the repository + - uses: stefanzweifel/git-auto-commit-action@v4 +``` + +> **Note** +> The Action has to be used in a Job that runs on a UNIX system (e.g. `ubuntu-latest`). The following is an extended example with all available options. @@ -111,8 +139,12 @@ jobs: php-cs-fixer: runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository. + contents: write + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} From 6656e542550b41d845d8d4844044eb181cb6fc6a Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 11 Feb 2023 21:29:21 +0100 Subject: [PATCH 11/62] Use actions/checkout@v3 in examples --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 28bab232..bc113e1e 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,7 @@ You must use `action/checkout@v2` or later versions to check out the repository. In non-`push` events, such as `pull_request`, make sure to specify the `ref` to check out: ```yaml -- uses: actions/checkout@v2 +- uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} ``` @@ -219,7 +219,7 @@ You can change this by creating a new [Personal Access Token (PAT)](https://gith storing the token as a secret in your repository and then passing the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step. ```yaml -- uses: actions/checkout@v2 +- uses: actions/checkout@v3 with: token: ${{ secrets.PAT }} ``` @@ -349,7 +349,7 @@ jobs: php-cs-fixer: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run php-cs-fixer uses: docker://oskarstark/php-cs-fixer-ga @@ -435,7 +435,7 @@ First, you have to create a new [Personal Access Token (PAT)](https://github.com store the token as a secret in your repository and pass the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step. ```yaml -- uses: actions/checkout@v2 +- uses: actions/checkout@v3 with: token: ${{ secrets.PAT }} ``` From 6436584fbbde9ffb372220e0dd9e42e96e6b03d8 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 11 Feb 2023 21:31:27 +0100 Subject: [PATCH 12/62] Fix Comment in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc113e1e..1ee654a5 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ jobs: permissions: # Give the default GITHUB_TOKEN write permission to commit and push the - # updated CHANGELOG back to the repository. + # added or changed files to the repository. contents: write steps: From c8254de74fb2d4577fe54a38cde3186515e9931c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Feb 2023 08:22:21 +0100 Subject: [PATCH 13/62] Bump bats from 1.8.2 to 1.9.0 (#282) Bumps [bats](https://github.com/bats-core/bats-core) from 1.8.2 to 1.9.0. - [Release notes](https://github.com/bats-core/bats-core/releases) - [Changelog](https://github.com/bats-core/bats-core/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/bats-core/bats-core/compare/v1.8.2...v1.9.0) --- updated-dependencies: - dependency-name: bats dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b012db72..da10b16e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "bats": "^1.8.2", + "bats": "^1.9.0", "bats-assert": "ztombol/bats-assert", "bats-support": "ztombol/bats-support" }, diff --git a/yarn.lock b/yarn.lock index dad53d06..a81d597e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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.8.2: - version "1.8.2" - resolved "https://registry.yarnpkg.com/bats/-/bats-1.8.2.tgz#bdbaa7690a18f04291b35144a8ce5435cffb8dc5" - integrity sha512-KLUIaPYuIMjqui8MbZmK84+CiwhjFVFAhFy5PXP0prLbkovc5faVzc+Qaowbz76F97zP573JrF31ODFAH7vzhg== +bats@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/bats/-/bats-1.9.0.tgz#251a255b58b631f210d75db6ba376a7c2be1b9fd" + integrity sha512-Z5BJaAmmHv/ujj7obhjEzJ//OL+ZtjVq0iRnHu+2fE9OeUaPMbJpBgYiOdNbDrG3E2hqe84/AXNnS/UiXl/UcA== From 8e108d701f702a9bfdff0350ee483743ca56b021 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 15 Feb 2023 19:44:45 +0100 Subject: [PATCH 14/62] Fix docs about using in public forks Update docs section about using the Action in public forks. Add warning about current issue when the forks lives under an organisation. Mark section about running a workflow in the head repository as outdated, as I was not able to reproduce this in test projects. See https://github.com/stefanzweifel/git-auto-commit-action/issues/211#issuecomment-1428849944 for more details. --- README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1ee654a5..ec585e6b 100644 --- a/README.md +++ b/README.md @@ -282,11 +282,14 @@ See [this announcement from GitHub](https://github.blog/2020-08-03-github-action
Expand to learn more -> **Note** +> **Note** > This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\ > Ensure your contributors enable "Allow edits by maintainers" when opening a pull request. ([Learn more](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)) \ > \ -> If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch. +> **If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch.** + +> **Warning** +> Due to limitations of GitHub, this Action currently can't push commits to a base repository, if the fork _lives_ under an organisation. See [github/community#6634](https://github.com/orgs/community/discussions/5634) and [this comment](https://github.com/stefanzweifel/git-auto-commit-action/issues/211#issuecomment-1428849944) for details. By default, this Action will not run on Pull Requests which have been opened by forks. (This is a limitation by GitHub, not by us.) However, there are a couple of ways to use this Actions in Workflows that should be triggered by forked repositories. @@ -312,10 +315,19 @@ on: jobs: php-cs-fixer: runs-on: ubuntu-latest + permissions: + contents: write + steps: - uses: actions/checkout@v3 with: + # Checkout the fork/head-repository and push changes to the fork. + # If you skip this, the base repository will be checked out and changes + # will be committed to the base repository! repository: ${{ github.event.pull_request.head.repo.full_name }} + + # Checkout the branch made in the fork. Will automatically push changes + # back to this branch. ref: ${{ github.head_ref }} - name: Run php-cs-fixer @@ -326,6 +338,11 @@ jobs: ### Workflow should run in **forked** repository +> **Warning** +> **This part of the documentation is outdated.** +> We were not able to configure a GitHub Action workflow for forks, that the workflow would run in the fork / head repository. +> Please let us know in the [discussions](https://github.com/stefanzweifel/git-auto-commit-action/discussions)-area, if and how you achieved that. + If the workflow should run in the forked repository, follow these steps: 1. In addition to listening to the `pull_request` event in your Workflow triggers, you have to add an additional event: `pull_request_target`. You can learn more about this event in [the GitHub docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target). @@ -380,7 +397,7 @@ For more information about running Actions on forks, see [this announcement from If you would like to use this Action to create a commit using [`--amend`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend) and [`--no-edit`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-edit) you need to make some adjustments. -> **Warning** +> **Warning** > You should understand the implications of rewriting history if you amend a commit that has already been published. [See rebasing](https://git-scm.com/docs/git-rebase#_recovering_from_upstream_rebase). First, you need to extract the previous commit message by using `git log -1 --pretty=%s`. From 0b5f8a533380e17b84a027ed83497bd5cfe3dfb2 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 28 Mar 2023 14:46:47 +0200 Subject: [PATCH 15/62] Update Test --- tests/git-auto-commit.bats | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index 179a5c7b..daf5bc0b 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -259,7 +259,7 @@ cat_github_output() { } @test "It applies commit user and author settings" { - INPUT_COMMIT_USER_NAME="A Single Test" + INPUT_COMMIT_USER_NAME="Custom User Name" INPUT_COMMIT_USER_EMAIL="single-test@github.com" INPUT_COMMIT_AUTHOR="A Single Test " @@ -269,7 +269,7 @@ cat_github_output() { assert_success - assert_line "INPUT_COMMIT_USER_NAME: A Single Test" + assert_line "INPUT_COMMIT_USER_NAME: Custom User Name" assert_line "INPUT_COMMIT_USER_EMAIL: single-test@github.com" assert_line "INPUT_COMMIT_AUTHOR: A Single Test " assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}" @@ -282,7 +282,7 @@ cat_github_output() { assert_output --partial "A Single Test" run git log -1 --pretty=format:'%cn' - assert_output --partial "A Single Test" + assert_output --partial "Custom User Name" run git log -1 --pretty=format:'%ce' assert_output --partial "single-test@github.com" From 9cc0a1f55de2aa04a36721ca84463dd520f70f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Amador=20Rodr=C3=ADguez?= Date: Mon, 3 Apr 2023 08:55:34 +0200 Subject: [PATCH 16/62] Seems like there is an extra space (#288) --- .github/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 69cfc0b3..6b9b1759 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -12,7 +12,7 @@ categories: - 'changelog:changed' - title: Deprecated labels: - - 'changelog:deprecated ' + - 'changelog:deprecated' - title: Removed labels: - 'changelog:removed' From 77a7b3fb3cefad3856cb5086bfb157ac1c32b008 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Jun 2023 09:20:59 +0200 Subject: [PATCH 17/62] Bump github/super-linter from 4 to 5 (#289) Bumps [github/super-linter](https://github.com/github/super-linter) from 4 to 5. - [Release notes](https://github.com/github/super-linter/releases) - [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md) - [Commits](https://github.com/github/super-linter/compare/v4...v5) --- updated-dependencies: - dependency-name: github/super-linter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index a01cc3fa..17d4c8e7 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -12,7 +12,7 @@ jobs: uses: actions/checkout@v3 - name: Lint Code Base - uses: github/super-linter@v4 + uses: github/super-linter@v5 env: VALIDATE_ALL_CODEBASE: false VALIDATE_MARKDOWN: false From 47a8ad5f38721f4b62f84ddd01aba6b281956891 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jul 2023 09:56:06 +0200 Subject: [PATCH 18/62] Bump bats from 1.9.0 to 1.10.0 (#293) Bumps [bats](https://github.com/bats-core/bats-core) from 1.9.0 to 1.10.0. - [Release notes](https://github.com/bats-core/bats-core/releases) - [Changelog](https://github.com/bats-core/bats-core/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/bats-core/bats-core/compare/v1.9.0...v1.10.0) --- updated-dependencies: - dependency-name: bats dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index da10b16e..40c35d7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "bats": "^1.9.0", + "bats": "^1.10.0", "bats-assert": "ztombol/bats-assert", "bats-support": "ztombol/bats-support" }, diff --git a/yarn.lock b/yarn.lock index a81d597e..50212d43 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/bats/-/bats-1.9.0.tgz#251a255b58b631f210d75db6ba376a7c2be1b9fd" - integrity sha512-Z5BJaAmmHv/ujj7obhjEzJ//OL+ZtjVq0iRnHu+2fE9OeUaPMbJpBgYiOdNbDrG3E2hqe84/AXNnS/UiXl/UcA== +bats@^1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/bats/-/bats-1.10.0.tgz#d22cb6e2d88fd39302167da237d710406d1587ce" + integrity sha512-yOQrC7npuCrN+Ic3TyjTjJlzHa0qlK3oEO6VAYPWwFeutx/GmpljIyB6uNSl/UTASyc2w4FgVuA/QMMf9OdsCw== From 3d1b5e078a85df99db0cb2441cd4309b09d86253 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 10:32:33 +0200 Subject: [PATCH 19/62] Bump actions/checkout from 3 to 4 (#302) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/git-auto-commit.yml | 2 +- .github/workflows/linter.yml | 2 +- .github/workflows/tests.yml | 2 +- .github/workflows/update-changelog.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/git-auto-commit.yml b/.github/workflows/git-auto-commit.yml index a217b1c8..d7db234d 100644 --- a/.github/workflows/git-auto-commit.yml +++ b/.github/workflows/git-auto-commit.yml @@ -16,7 +16,7 @@ jobs: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use git-auto-commit-action id: "auto-commit-action" diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 17d4c8e7..e355374d 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Lint Code Base uses: github/super-linter@v5 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 48f3a84b..35ee1e2c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install testing dependencies run: yarn install diff --git a/.github/workflows/update-changelog.yaml b/.github/workflows/update-changelog.yaml index 02c4e667..691e6dc3 100644 --- a/.github/workflows/update-changelog.yaml +++ b/.github/workflows/update-changelog.yaml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: master From 10944650cd54362ae9200814cbb06c657132951d Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 4 Oct 2023 15:33:04 +0200 Subject: [PATCH 20/62] Use actions/checkout v4 in examples https://github.com/stefanzweifel/git-auto-commit-action/pull/302#issuecomment-1745974288 --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ec585e6b..9c2d9e0d 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ jobs: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Other steps that change files in the repository @@ -144,7 +144,7 @@ jobs: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} @@ -201,7 +201,7 @@ You must use `action/checkout@v2` or later versions to check out the repository. In non-`push` events, such as `pull_request`, make sure to specify the `ref` to check out: ```yaml -- uses: actions/checkout@v3 +- uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} ``` @@ -219,7 +219,7 @@ You can change this by creating a new [Personal Access Token (PAT)](https://gith storing the token as a secret in your repository and then passing the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step. ```yaml -- uses: actions/checkout@v3 +- uses: actions/checkout@v4 with: token: ${{ secrets.PAT }} ``` @@ -319,7 +319,7 @@ jobs: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: # Checkout the fork/head-repository and push changes to the fork. # If you skip this, the base repository will be checked out and changes @@ -366,7 +366,7 @@ jobs: php-cs-fixer: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run php-cs-fixer uses: docker://oskarstark/php-cs-fixer-ga @@ -408,7 +408,7 @@ Finally, you have to use `push_options: '--force'` to overwrite the git history The steps in your workflow might look like this: ```yaml -- uses: actions/checkout@master +- uses: actions/checkout@4 with: # Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history) fetch-depth: 2 @@ -452,7 +452,7 @@ First, you have to create a new [Personal Access Token (PAT)](https://github.com store the token as a secret in your repository and pass the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step. ```yaml -- uses: actions/checkout@v3 +- uses: actions/checkout@v4 with: token: ${{ secrets.PAT }} ``` From 43818d504497ae1cf89266ac8e6b88253fd828b3 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Fri, 6 Oct 2023 19:30:48 +0200 Subject: [PATCH 21/62] Fix Typo --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index a964e7f8..6fe017a0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -40,7 +40,7 @@ _main() { _add_files # Check dirty state of repo again using git-diff. - # (git-diff detects beter if CRLF of files changes and does NOT + # (git-diff detects better if CRLF of files changes and does NOT # proceed, if only CRLF changes are detected. See #241 and #265 # for more details.) if [ -n "$(git diff --staged)" ] || "$INPUT_SKIP_DIRTY_CHECK"; then From 8756aa072ef5b4a080af5dc8fef36c5d586e521d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E4=BA=95?= <56185180+ryudaitakai@users.noreply.github.com> Date: Sat, 7 Oct 2023 02:43:01 +0900 Subject: [PATCH 22/62] Update node version to node20 (#300) Co-authored-by: ryudai.takai --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 5e67a1f7..8192c950 100644 --- a/action.yml +++ b/action.yml @@ -81,7 +81,7 @@ outputs: description: Full hash of the created commit. Only present if the "changes_detected" output is "true". runs: - using: 'node16' + using: 'node20' main: 'index.js' branding: From e27a68931bfdedc02d161959134e07e91ffaafeb Mon Sep 17 00:00:00 2001 From: stefanzweifel Date: Fri, 6 Oct 2023 17:55:19 +0000 Subject: [PATCH 23/62] Update CHANGELOG --- CHANGELOG.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3658910a..2d611c76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,31 @@ 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.16.0...HEAD) +## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.0...HEAD) > TBD +## [v5.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.16.0...v5.0.0) - 2023-10-06 + +New major release that bumps the default runtime to Node 20. There are no other breaking changes. + +### Changed + +- Update node version to node20 ([#300](https://github.com/stefanzweifel/git-auto-commit-action/pull/300)) [@ryudaitakai](https://github.com/@ryudaitakai) +- Add _log and _set_github_output functions ([#273](https://github.com/stefanzweifel/git-auto-commit-action/pull/273)) [@stefanzweifel](https://github.com/@stefanzweifel) + +### Fixed + +- Seems like there is an extra space ([#288](https://github.com/stefanzweifel/git-auto-commit-action/pull/288)) [@pedroamador](https://github.com/@pedroamador) +- Fix git-auto-commit.yml ([#277](https://github.com/stefanzweifel/git-auto-commit-action/pull/277)) [@zcong1993](https://github.com/@zcong1993) + +### Dependency Updates + +- Bump actions/checkout from 3 to 4 ([#302](https://github.com/stefanzweifel/git-auto-commit-action/pull/302)) [@dependabot](https://github.com/@dependabot) +- Bump bats from 1.9.0 to 1.10.0 ([#293](https://github.com/stefanzweifel/git-auto-commit-action/pull/293)) [@dependabot](https://github.com/@dependabot) +- Bump github/super-linter from 4 to 5 ([#289](https://github.com/stefanzweifel/git-auto-commit-action/pull/289)) [@dependabot](https://github.com/@dependabot) +- Bump bats from 1.8.2 to 1.9.0 ([#282](https://github.com/stefanzweifel/git-auto-commit-action/pull/282)) [@dependabot](https://github.com/@dependabot) + ## [v4.16.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.4...v4.16.0) - 2022-12-02 ### Changed From eb38c210f2fc7b4533fe335ac7c74cbe8715ee5e Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Fri, 6 Oct 2023 19:56:27 +0200 Subject: [PATCH 24/62] Use v5 in update-changelog Workflow --- .github/workflows/update-changelog.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-changelog.yaml b/.github/workflows/update-changelog.yaml index 691e6dc3..1a03dfc7 100644 --- a/.github/workflows/update-changelog.yaml +++ b/.github/workflows/update-changelog.yaml @@ -27,7 +27,7 @@ jobs: latest-version: ${{ github.event.release.name }} - name: Commit updated CHANGELOG - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@v5 with: branch: master commit_message: Update CHANGELOG From 98d2782f49833831d777f51f3ada1d7ac3073f7d Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Fri, 6 Oct 2023 19:56:33 +0200 Subject: [PATCH 25/62] Use v5 in README --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9c2d9e0d..c72dcecd 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Adding git-auto-commit to your Workflow only takes a couple lines of code. 2. Add the following step at the end of your job, after other steps that might add or change files. ```yaml -- uses: stefanzweifel/git-auto-commit-action@v4 +- uses: stefanzweifel/git-auto-commit-action@v5 ``` Your Workflow should look similar to this example. @@ -44,7 +44,7 @@ jobs: # Other steps that change files in the repository # Commit all changed files back to the repository - - uses: stefanzweifel/git-auto-commit-action@v4 + - uses: stefanzweifel/git-auto-commit-action@v5 ``` > **Note** @@ -53,7 +53,7 @@ jobs: The following is an extended example with all available options. ```yaml -- uses: stefanzweifel/git-auto-commit-action@v4 +- uses: stefanzweifel/git-auto-commit-action@v5 with: # Optional. Commit message for the created commit. # Defaults to "Apply automatic changes" @@ -151,7 +151,7 @@ jobs: - name: Run php-cs-fixer uses: docker://oskarstark/php-cs-fixer-ga - - uses: stefanzweifel/git-auto-commit-action@v4 + - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Apply php-cs-fixer changes ``` @@ -258,7 +258,7 @@ The example below can be used as a starting point to generate a multiline commit # Quick and dirty step to get rid of the temporary file holding the commit message - run: rm -rf commitmessage.txt - - uses: stefanzweifel/git-auto-commit-action@v4 + - uses: stefanzweifel/git-auto-commit-action@v5 id: commit with: commit_message: ${{ steps.commit_message_step.outputs.commit_message }} @@ -333,7 +333,7 @@ jobs: - name: Run php-cs-fixer uses: docker://oskarstark/php-cs-fixer-ga - - uses: stefanzweifel/git-auto-commit-action@v4 + - uses: stefanzweifel/git-auto-commit-action@v5 ``` ### Workflow should run in **forked** repository @@ -371,7 +371,7 @@ jobs: - name: Run php-cs-fixer uses: docker://oskarstark/php-cs-fixer-ga - - uses: stefanzweifel/git-auto-commit-action@v4 + - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Apply php-cs-fixer changes ``` @@ -420,7 +420,7 @@ The steps in your workflow might look like this: run: | echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT -- uses: stefanzweifel/git-auto-commit-action@v4 +- uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: ${{ steps.last-commit-message.outputs.msg }} commit_options: '--amend --no-edit' @@ -465,7 +465,7 @@ You can learn more about Personal Access Token in the [GitHub documentation](htt If you go the "force pushes" route, you have to enable force pushes to a protected branch (See [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to use force push like this. ```yaml - - uses: stefanzweifel/git-auto-commit-action@v4 + - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Apply php-cs-fixer changes push_options: --force @@ -495,7 +495,7 @@ This is due to the fact, that the `*.md`-glob is expanded before sending it to ` To fix this add `disable_globbing: true` to your Workflow. ```yaml -- uses: stefanzweifel/git-auto-commit-action@v4 +- uses: stefanzweifel/git-auto-commit-action@v5 with: file_pattern: '*.md' disable_globbing: true @@ -523,7 +523,7 @@ yarn test 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). -We also provide major version tags to make it easier to always use the latest release of a major version. For example, you can use `stefanzweifel/git-auto-commit-action@v4` to always use the latest release of the current major version. +We also provide major version tags to make it easier to always use the latest release of a major version. For example, you can use `stefanzweifel/git-auto-commit-action@v5` to always use the latest release of the current major version. (More information about this [here](https://help.github.com/en/actions/building-actions/about-actions#versioning-your-action).) ## Credits From 8036286d3751929c947d18324a45433db4ff357f Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 12 Dec 2023 20:38:06 +0100 Subject: [PATCH 26/62] Use new Markdown Alerts in README --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c72dcecd..9182c12f 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ jobs: - uses: stefanzweifel/git-auto-commit-action@v5 ``` -> **Note** +> [!NOTE] > The Action has to be used in a Job that runs on a UNIX system (e.g. `ubuntu-latest`). The following is an extended example with all available options. @@ -282,13 +282,13 @@ See [this announcement from GitHub](https://github.blog/2020-08-03-github-action
Expand to learn more -> **Note** +> [!NOTE] > This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\ > Ensure your contributors enable "Allow edits by maintainers" when opening a pull request. ([Learn more](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)) \ > \ > **If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch.** -> **Warning** +> [!WARNING] > Due to limitations of GitHub, this Action currently can't push commits to a base repository, if the fork _lives_ under an organisation. See [github/community#6634](https://github.com/orgs/community/discussions/5634) and [this comment](https://github.com/stefanzweifel/git-auto-commit-action/issues/211#issuecomment-1428849944) for details. By default, this Action will not run on Pull Requests which have been opened by forks. (This is a limitation by GitHub, not by us.) @@ -338,7 +338,7 @@ jobs: ### Workflow should run in **forked** repository -> **Warning** +> [!WARNING] > **This part of the documentation is outdated.** > We were not able to configure a GitHub Action workflow for forks, that the workflow would run in the fork / head repository. > Please let us know in the [discussions](https://github.com/stefanzweifel/git-auto-commit-action/discussions)-area, if and how you achieved that. @@ -397,7 +397,7 @@ For more information about running Actions on forks, see [this announcement from If you would like to use this Action to create a commit using [`--amend`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend) and [`--no-edit`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-edit) you need to make some adjustments. -> **Warning** +> [!CAUTION] > You should understand the implications of rewriting history if you amend a commit that has already been published. [See rebasing](https://git-scm.com/docs/git-rebase#_recovering_from_upstream_rebase). First, you need to extract the previous commit message by using `git log -1 --pretty=%s`. @@ -458,7 +458,7 @@ store the token as a secret in your repository and pass the new token to the [`a ``` You can learn more about Personal Access Token in the [GitHub documentation](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). -> **Note** +> [!TIP] > If you're working in an organisation, and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens. From 8d90676eefd6ee2df2214033002d76f2ce6b6989 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 12 Dec 2023 20:38:26 +0100 Subject: [PATCH 27/62] Little Doc Updates --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9182c12f..c8e0493c 100644 --- a/README.md +++ b/README.md @@ -270,9 +270,9 @@ Using command lines options needs to be done manually for each workflow which yo - [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer)) -### Push to forks from private repositories +### Use in forks from private repositories -By default, GitHub Actions doesn't run Workflows on forks from private repositories. To enable Actions for **private** repositories enable "Run workflows from pull requests" in your repository settings. +By default, GitHub Actions doesn't run Workflows on forks from **private** repositories. To enable Actions for **private** repositories enable "Run workflows from pull requests" in your repository settings. See [this announcement from GitHub](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/) or the [GitHub docs](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository#enabling-workflows-for-private-repository-forks) for details. @@ -461,8 +461,7 @@ You can learn more about Personal Access Token in the [GitHub documentation](htt > [!TIP] > If you're working in an organisation, and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens. - -If you go the "force pushes" route, you have to enable force pushes to a protected branch (See [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to use force push like this. +If you go the "force pushes" route, you have to enable force pushes to a protected branch (see [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to use force push like this. ```yaml - uses: stefanzweifel/git-auto-commit-action@v5 @@ -477,7 +476,7 @@ This is due to limitations set up by GitHub, [commits made by this Action do not ### Pathspec 'x' did not match any files -If you're using the Action with a custom `file_pattern` and the Action throws a fatal error with the message "Pathspec 'file-pattern' did not match any files", the problem is probably that no file for the pattern exists in the repository. +If you're using the Action with a custom `file_pattern` and the Action throws a fatal error with the message "Pathspec 'file-pattern' did not match any files", the problem is probably that no file for the pattern **exists** in the repository. `file_pattern` is used both for `git-status` and `git-add` in this Action. `git-add` will throw a fatal error, if for example, you use a file pattern like `*.js *.ts` but no `*.ts` files exist in your projects' repository. From 2818fe7949d2daf9e2b5d7d808ca2ca11ccf70ad Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 12 Dec 2023 20:42:25 +0100 Subject: [PATCH 28/62] Add Alert about pull_request_target https://github.com/stefanzweifel/git-auto-commit-action/issues/211#issuecomment-1837270114 --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c8e0493c..03340bf0 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,15 @@ However, there are a couple of ways to use this Actions in Workflows that should ### Workflow should run in **base** repository -The workflow below runs whenever a commit is pushed to the `main`-branch or when activity on a pull request happens, by listening to the [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) event. +> [!CAUTION] +> The following section explains how you can use git-auto-commit in combination with the `pull_request_target` trigger. +> **Using `pull_request_target` in your workflows can lead to repository compromise as [mentioned](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) by GitHub's own security team. This means, that a bad actor could potentially leak/steal your GitHub Actions repository secrets.** +> Please be aware of this risk when using `pull_request_target` in your workflows. +> +> If your workflow runs code-fixing tools, consider running the workflow on your default branch by listening to the `push` event or use a third-party tool like [autofix.ci](https://autofix.ci/). +> We keep this documentation around, as many questions came in over the years, on how to use this action for public forks. + +The workflow below runs whenever a commit is pushed to the `main`-branch or when activity on a pull request happens, by listening to the [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) event. If the workflow is triggered by the `pull_request_target`-event, the workflow will run in the context of the base of the pull request, rather than in the context of the merge commit, as the `pull_request` event does. In other words, this will allow your workflow to be run in the repository where the pull request is opened to and will push changes back to the fork. From 29183a25ec7450c8f6fbab7ff22ccd42d8ab7416 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 12 Dec 2023 20:45:33 +0100 Subject: [PATCH 29/62] Remove outdated docs --- README.md | 66 +++---------------------------------------------------- 1 file changed, 3 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 03340bf0..040fc3b6 100644 --- a/README.md +++ b/README.md @@ -279,9 +279,6 @@ See [this announcement from GitHub](https://github.blog/2020-08-03-github-action ### Use in forks from public repositories -
-Expand to learn more - > [!NOTE] > This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\ > Ensure your contributors enable "Allow edits by maintainers" when opening a pull request. ([Learn more](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)) \ @@ -297,11 +294,11 @@ However, there are a couple of ways to use this Actions in Workflows that should ### Workflow should run in **base** repository > [!CAUTION] -> The following section explains how you can use git-auto-commit in combination with the `pull_request_target` trigger. -> **Using `pull_request_target` in your workflows can lead to repository compromise as [mentioned](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) by GitHub's own security team. This means, that a bad actor could potentially leak/steal your GitHub Actions repository secrets.** +> The following section explains how you can use git-auto-commit in combination with the `pull_request_target` trigger. +> **Using `pull_request_target` in your workflows can lead to repository compromise as [mentioned](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) by GitHub's own security team. This means, that a bad actor could potentially leak/steal your GitHub Actions repository secrets.** > Please be aware of this risk when using `pull_request_target` in your workflows. > -> If your workflow runs code-fixing tools, consider running the workflow on your default branch by listening to the `push` event or use a third-party tool like [autofix.ci](https://autofix.ci/). +> If your workflow runs code-fixing tools, consider running the workflow on your default branch by listening to the `push` event or use a third-party tool like [autofix.ci](https://autofix.ci/). > We keep this documentation around, as many questions came in over the years, on how to use this action for public forks. The workflow below runs whenever a commit is pushed to the `main`-branch or when activity on a pull request happens, by listening to the [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) event. @@ -344,65 +341,10 @@ jobs: - uses: stefanzweifel/git-auto-commit-action@v5 ``` -### Workflow should run in **forked** repository - -> [!WARNING] -> **This part of the documentation is outdated.** -> We were not able to configure a GitHub Action workflow for forks, that the workflow would run in the fork / head repository. -> Please let us know in the [discussions](https://github.com/stefanzweifel/git-auto-commit-action/discussions)-area, if and how you achieved that. - -If the workflow should run in the forked repository, follow these steps: - -1. In addition to listening to the `pull_request` event in your Workflow triggers, you have to add an additional event: `pull_request_target`. You can learn more about this event in [the GitHub docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target). -2. GitHub Action has to be enabled on the forked repository. \ -For security reasons, GitHub does not automatically enable GitHub Actions on forks. The user has to explicitly enable GitHub Actions in the "Actions"-tab of the forked repository. (Mention this in your projects README or CONTRIBUTING.md!) - -After you have added the `pull_request_target` to your desired Workflow and the forked repository has enabled Actions and a new Pull Request is opened, the Workflow will run **on the forked repository**. - -Due to the fact that the Workflow is not run on the repository the Pull Request is opened in, you won't see any status indicators inside the Pull Request. - -#### Example - -The following workflow runs `php-cs-fixer` (a code linter and fixer for PHP) when a `pull_request` is opened. We've added the `pull_request_target`-trigger too, to make it work for forks. - -```yaml -name: Format PHP - -on: [push, pull_request, pull_request_target] - -jobs: - php-cs-fixer: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Run php-cs-fixer - uses: docker://oskarstark/php-cs-fixer-ga - - - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: Apply php-cs-fixer changes -``` - -Next time a user forks your project **and** enabled GitHub Actions **and** opened a Pull Request, the Workflow will run on the **forked** repository and will push commits to the same branch. - -Here's how the Pull Request will look like: - -![Screenshot of a Pull Request from a Fork](https://user-images.githubusercontent.com/1080923/90955964-9c74c080-e482-11ea-8097-aa7f5161f50e.png) - - -As you can see, your contributors have to go through hoops to make this work. **For Workflows which run linters and fixers (like the example above) we recommend running them when a push happens on the `main`-branch.** - - For more information about running Actions on forks, see [this announcement from GitHub](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/). -
- ### Using `--amend` and `--no-edit` as commit options -
-Expand to learn more - If you would like to use this Action to create a commit using [`--amend`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend) and [`--no-edit`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-edit) you need to make some adjustments. > [!CAUTION] @@ -438,8 +380,6 @@ The steps in your workflow might look like this: See discussion in [#159](https://github.com/stefanzweifel/git-auto-commit-action/issues/159#issuecomment-845347950) for details. -
- ## Troubleshooting ### Action does not push commit to repository From 12f68633e45c72459cd040c868605f2471c7f63b Mon Sep 17 00:00:00 2001 From: Nikita Panuhin Date: Sun, 24 Dec 2023 07:35:30 +0100 Subject: [PATCH 30/62] Clarify `commit_author` input option (#315) * Clarify `commit_author` input option * Update README.md --------- Co-authored-by: Stefan Zweifel --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 040fc3b6..49107a16 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The following is an extended example with all available options. # Optional commit user and author settings commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]" commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com" - commit_author: Author # defaults to author of the commit that triggered the run + commit_author: Author # defaults to "username ", where "username" belongs to the author of the commit that triggered the run # Optional. Tag name being created in the local repository and # pushed to remote repository and defined branch. @@ -353,6 +353,8 @@ If you would like to use this Action to create a commit using [`--amend`](https: First, you need to extract the previous commit message by using `git log -1 --pretty=%s`. Then you need to provide this last commit message to the Action through the `commit_message` input option. +By default, the commit author is changed to `username `, where `username` is the name of the user who triggered the workflow (The [`github.actor`](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context) context is used here). If you want to preserve the name and email of the original author, you must extract them from the last commit and provide them to the Action through the `commit_author` input option. + Finally, you have to use `push_options: '--force'` to overwrite the git history on the GitHub remote repository. (git-auto-commit will not do a `git-rebase` for you!) The steps in your workflow might look like this: @@ -366,13 +368,15 @@ The steps in your workflow might look like this: # Other steps in your workflow to trigger a changed file - name: Get last commit message - id: last-commit-message + id: last-commit run: | - echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT + echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT + echo "author=$(git log -1 --pretty=\"%an <%ae>\")" >> $GITHUB_OUTPUT - uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: ${{ steps.last-commit-message.outputs.msg }} + commit_author: ${{ steps.last-commit.outputs.author }} + commit_message: ${{ steps.last-commit.outputs.message }} commit_options: '--amend --no-edit' push_options: '--force' skip_fetch: true From 4d160c5e4d67c62e67f03ae49aa38359e964139a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 07:16:57 +0100 Subject: [PATCH 31/62] Bump release-drafter/release-drafter from 5 to 6 (#319) --- .github/workflows/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 6106be2d..1f36cb9d 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -15,6 +15,6 @@ jobs: contents: write steps: - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e040c596f0a65570b339c60818081175bcf82d11 Mon Sep 17 00:00:00 2001 From: Philip Couling Date: Thu, 22 Feb 2024 07:26:06 +0000 Subject: [PATCH 32/62] Linux is not UNIX (#321) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 49107a16..5eb57485 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ jobs: ``` > [!NOTE] -> The Action has to be used in a Job that runs on a UNIX system (e.g. `ubuntu-latest`). +> The Action has to be used in a Job that runs on a UNIX-like system (e.g. `ubuntu-latest`). The following is an extended example with all available options. From 9b5e5ee10a5c7b2e05d5f25da265a1c73b24e6a6 Mon Sep 17 00:00:00 2001 From: Christian Vermeulen Date: Fri, 15 Mar 2024 16:06:58 +0100 Subject: [PATCH 33/62] Add step id explanation for output in README.md (#324) --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 5eb57485..afd09f6c 100644 --- a/README.md +++ b/README.md @@ -167,9 +167,16 @@ You can use these outputs to trigger other Actions in your Workflow run based on - `changes_detected`: Returns either "true" or "false" if the repository was dirty and files have changed. - `commit_hash`: Returns the full hash of the commit if one was created. +**⚠️ When using outputs, the step needs to be given an id. See example below.** + ### Example ```yaml + - uses: stefanzweifel/git-auto-commit-action@v5 + id: auto-commit-action #mandatory for the output to show up in ${{ steps }} + with: + commit_message: Apply php-cs-fixer changes + - name: "Run if changes have been detected" if: steps.auto-commit-action.outputs.changes_detected == 'true' run: echo "Changes!" From b0f4d47f590e46dfe55fea81b3b068cb0aab8678 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 08:29:07 +0100 Subject: [PATCH 34/62] Bump bats from 1.10.0 to 1.11.0 (#325) Bumps [bats](https://github.com/bats-core/bats-core) from 1.10.0 to 1.11.0. - [Release notes](https://github.com/bats-core/bats-core/releases) - [Changelog](https://github.com/bats-core/bats-core/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/bats-core/bats-core/compare/v1.10.0...v1.11.0) --- updated-dependencies: - dependency-name: bats dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 40c35d7a..d71dd690 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "bats": "^1.10.0", + "bats": "^1.11.0", "bats-assert": "ztombol/bats-assert", "bats-support": "ztombol/bats-support" }, diff --git a/yarn.lock b/yarn.lock index 50212d43..65fc8101 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/bats/-/bats-1.10.0.tgz#d22cb6e2d88fd39302167da237d710406d1587ce" - integrity sha512-yOQrC7npuCrN+Ic3TyjTjJlzHa0qlK3oEO6VAYPWwFeutx/GmpljIyB6uNSl/UTASyc2w4FgVuA/QMMf9OdsCw== +bats@^1.11.0: + version "1.11.0" + resolved "https://registry.yarnpkg.com/bats/-/bats-1.11.0.tgz#40281f021f5befcc10da54ed5674aa5b181f4953" + integrity sha512-qiKdnS4ID3bJ1MaEOKuZe12R4w+t+psJF0ICj+UdkiHBBoObPMHv8xmD3w6F4a5qwUyZUHS+413lxENBNy8xcQ== From 8621497c8c39c72f3e2a999a26b4ca1b5058a842 Mon Sep 17 00:00:00 2001 From: Constantin Comendant Date: Thu, 11 Apr 2024 21:00:36 +0200 Subject: [PATCH 35/62] Fail if attempting to execute git commands in a directory that is not a git-repo. (#326) * Fail (and log message) if attempting to execute git commands in a directory that is not a git-repo. * Add Test * Code Formatting --------- Co-authored-by: Constantin Comendant Co-authored-by: Stefan Zweifel --- entrypoint.sh | 9 ++++++++- tests/git-auto-commit.bats | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 6fe017a0..bff98e0e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -82,8 +82,15 @@ _git_is_dirty() { echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}"; read -r -a INPUT_FILE_PATTERN_EXPANDED <<< "$INPUT_FILE_PATTERN"; + # capture stderr + gitStatusMessage="$((git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}} >/dev/null ) 2>&1)"; # shellcheck disable=SC2086 - [ -n "$(git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}})" ] + gitStatus="$(git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}})"; + if [ $? -ne 0 ]; then + _log "error" "git-status failed with:<$gitStatusMessage>"; + exit 1; + fi + [ -n "$gitStatus" ] } _switch_to_branch() { diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index daf5bc0b..d08597cc 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -8,6 +8,7 @@ setup() { export FAKE_LOCAL_REPOSITORY="${BATS_TEST_DIRNAME}/tests_local_repository" export FAKE_REMOTE="${BATS_TEST_DIRNAME}/tests_remote_repository" export FAKE_TEMP_LOCAL_REPOSITORY="${BATS_TEST_DIRNAME}/tests_clone_of_remote_repository" + export FAKE_FOLDER_WITHOUT_GIT_REPO="/tmp/tests_folder_without_git_repo" # While it is likely the GitHub hosted runners will use master as the default branch, # locally anyone may change that. So for tests lets grab whatever is currently set @@ -58,6 +59,7 @@ teardown() { rm -rf "${FAKE_LOCAL_REPOSITORY}" rm -rf "${FAKE_REMOTE}" rm -rf "${FAKE_TEMP_LOCAL_REPOSITORY}" + rm -rf "${INPUT_REPOSITORY}" if [ -z ${GITHUB_OUTPUT+x} ]; then echo "GITHUB_OUTPUT is not set" @@ -1112,3 +1114,14 @@ END run git log -n 1 assert_output --partial $COMMIT_MESSAGE } + +@test "It exits with error message if entrypoint.sh is being run not in a git repository" { + INPUT_REPOSITORY="${FAKE_FOLDER_WITHOUT_GIT_REPO}" + + mkdir "${INPUT_REPOSITORY}" + + run git_auto_commit + + assert_failure; + assert_line "::error::git-status failed with:" +} From 896cc0d2253902339fdc3309717e76c7aed4983a Mon Sep 17 00:00:00 2001 From: stefanzweifel Date: Fri, 12 Apr 2024 06:47:58 +0000 Subject: [PATCH 36/62] Update CHANGELOG --- CHANGELOG.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d611c76..9fcbddf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,27 @@ 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/v5.0.0...HEAD) +## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.1...HEAD) > TBD +## [v5.0.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.0...v5.0.1) - 2024-04-12 + +### Fixed + +- Fail if attempting to execute git commands in a directory that is not a git-repo. ([#326](https://github.com/stefanzweifel/git-auto-commit-action/pull/326)) [@ccomendant](https://github.com/@ccomendant) + +### Dependency Updates + +- Bump bats from 1.10.0 to 1.11.0 ([#325](https://github.com/stefanzweifel/git-auto-commit-action/pull/325)) [@dependabot](https://github.com/@dependabot) +- Bump release-drafter/release-drafter from 5 to 6 ([#319](https://github.com/stefanzweifel/git-auto-commit-action/pull/319)) [@dependabot](https://github.com/@dependabot) + +### Misc + +- Clarify `commit_author` input option ([#315](https://github.com/stefanzweifel/git-auto-commit-action/pull/315)) [@npanuhin](https://github.com/@npanuhin) +- Add step id explanation for output in README.md ([#324](https://github.com/stefanzweifel/git-auto-commit-action/pull/324)) [@ChristianVermeulen](https://github.com/@ChristianVermeulen) +- Linux is not UNIX ([#321](https://github.com/stefanzweifel/git-auto-commit-action/pull/321)) [@couling](https://github.com/@couling) + ## [v5.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.16.0...v5.0.0) - 2023-10-06 New major release that bumps the default runtime to Node 20. There are no other breaking changes. From 4b8a201e31cadd9829df349894b28c54e6c19fe6 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 13 Apr 2024 10:35:11 +0200 Subject: [PATCH 37/62] Add with ref github.head_ref to README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index afd09f6c..e3f71b46 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,11 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} - # Other steps that change files in the repository + # Other steps that change files in the repository go here + # … # Commit all changed files back to the repository - uses: stefanzweifel/git-auto-commit-action@v5 From ee5525316dadb81d312150a269eec33539f9cc4c Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Tue, 2 Jul 2024 20:41:34 +0200 Subject: [PATCH 38/62] Update GPG Signing section in README --- README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e3f71b46..1e53df78 100644 --- a/README.md +++ b/README.md @@ -274,11 +274,32 @@ The example below can be used as a starting point to generate a multiline commit commit_message: ${{ steps.commit_message_step.outputs.commit_message }} ``` -### Signing Commits & Other Git Command Line Options +### Signing Commits -Using command lines options needs to be done manually for each workflow which you require the option enabled. So for example signing commits requires you to import the gpg signature each and every time. The following list of actions are worth checking out if you need to automate these tasks regularly. +If you would like to sign your commits using a GPG key, you will need to use an additional action. +You can use the [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) action and follow its setup instructions. -- [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer)) +As git-auto-commit by default does not use **your** username and email when creating a commit, you have to override these values in your workflow. + +```yml +- name: "Import GPG key" + id: import-gpg + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + +- name: "Commit and push changes" + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_author: "${{ steps.import-gpg.outputs.name }} <${{ steps.import-gpg.outputs.email }}>" + commit_user_name: ${{ steps.import-gpg.outputs.name }} + commit_user_email: ${{ steps.import-gpg.outputs.email }} +``` + +See discussion [#334](https://github.com/stefanzweifel/git-auto-commit-action/discussions/334) for details. ### Use in forks from private repositories From 5f3fa8aed3bd643aa59d805140a62d1277aaa0f7 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 6 Jul 2024 11:43:22 +0200 Subject: [PATCH 39/62] Add docs about .github/workflows pushes See #322 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 1e53df78..e2537c82 100644 --- a/README.md +++ b/README.md @@ -427,6 +427,15 @@ please update your Workflow configuration and usage of [`actions/checkout`](http Updating the `token` value with a Personal Access Token should fix your issues. +### git-auto-commit fails to push commit that creates or udpates files in `.github/workflows/` + +The default `GITHUB_TOKEN` issued by GitHub Action does not have permission to make changes to workflow files located in `.github/workflows/`. +To fix this, please create a personal access token (PAT) and pass the token to the `actions/checkout`-step in your workflow. (Similar to [how to push to protected branches](https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#push-to-protected-branches)). + +If a PAT does not work for you, you could also create a new GitHub app and use it's token in your workflows. See [this comment in #87](https://github.com/stefanzweifel/git-auto-commit-action/issues/87#issuecomment-1939138661) for details. + +See [#322](https://github.com/stefanzweifel/git-auto-commit-action/issues/322) for details and discussions around this topic. + ### Push to protected branches If your repository uses [protected branches](https://help.github.com/en/github/administering-a-repository/configuring-protected-branches) you have to make some changes to your Workflow for the Action to work properly: You need a Personal Access Token and you either have to allow force pushes or the Personal Access Token needs to belong to an Administrator. From efd424db0f98c02ad37e480b4795a652992eb471 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 6 Jul 2024 12:00:09 +0200 Subject: [PATCH 40/62] Fix link to "new feature request" --- .github/ISSUE_TEMPLATE/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index edb1c778..640f4257 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -4,5 +4,5 @@ contact_links: url: https://github.com/stefanzweifel/git-auto-commit-action/discussions/new?category=help about: If you can't get something to work the way you expect, open a question in our discussion forums. - name: Feature Request - url: https://github.com/tailwindlabs/tailwindcss/discussions/new?category=ideas + url: https://github.com/stefanzweifel/git-auto-commit-action/discussions/new?category=ideas about: 'Suggest any ideas you have using our discussion forums.' From 7d779d00676848386f749046a215f8938d236f39 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 6 Jul 2024 12:06:47 +0200 Subject: [PATCH 41/62] Update Bug Repo Form --- .github/ISSUE_TEMPLATE/bug.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml index 3221ab95..bca68fab 100644 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -5,7 +5,7 @@ body: - type: markdown attributes: value: | - Before opening a bug report, please search for the behaviour in the existing issues. + Before opening a bug report, please search for the behaviour in existing issues or discussions. --- @@ -17,7 +17,7 @@ body: description: "Which exact version of git-auto-commit are you using in your Workflow?" placeholder: "v4.14.0" validations: - required: true + required: true - type: dropdown id: machine attributes: @@ -33,7 +33,7 @@ body: id: bug-description attributes: label: Bug description - description: What exactly happened? + description: What exactly happened? Please describe your problem in detail. validations: required: true - type: textarea @@ -52,7 +52,7 @@ body: id: example-workflow attributes: label: Example Workflow - description: Please share your GitHub Actions workflow which causes the bug. We use this to reproduce the error. No need for backticks here. + description: Please share the YAML-code of your GitHub Actions workflow which causes the bug. We use this to reproduce the error. If the workflow is in a private repostory, please provide a minimal example. (No need for backticks here, the pasted code will be correctly formatted.) render: yaml validations: required: true @@ -60,5 +60,10 @@ body: id: logs attributes: label: Relevant log output - description: If applicable, provide relevant log output. No need for backticks here. + description: If applicable, provide relevant log output. Please copy and paste the output here, and make sure to remove any sensitive information. (No need for backticks here, the pasted code will be correctly formatted.) render: shell + - type: input + id: repository + attributes: + label: Repository + description: If applicable, please provide the repository where the bug occurred. From 18157e6f3b5f11546d1c1b46e4891d0bdccb113c Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 6 Jul 2024 12:07:25 +0200 Subject: [PATCH 42/62] Update bug.yaml --- .github/ISSUE_TEMPLATE/bug.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml index bca68fab..1d09ac07 100644 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -63,7 +63,7 @@ body: description: If applicable, provide relevant log output. Please copy and paste the output here, and make sure to remove any sensitive information. (No need for backticks here, the pasted code will be correctly formatted.) render: shell - type: input - id: repository + id: repository-url attributes: label: Repository description: If applicable, please provide the repository where the bug occurred. From 55a82ca24f1c4585f348f92fa0de24650ecae7a2 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 6 Jul 2024 15:14:44 +0200 Subject: [PATCH 43/62] Add Section on preventing infinite loops to README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e2537c82..873e2ffc 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,12 @@ If you create a personal access token, apply the `repo` and `workflow` scopes. If you work in an organization and don't want to create a PAT from your personal account, we recommend using a [robot account](https://docs.github.com/en/github/getting-started-with-github/types-of-github-accounts) for the token. +### Prevent Infinite Loop when using a Personal Access Token + +If you're using a Personal Access Token (PAT) to push commits to GitHub repository, the resulting commit or push can trigger other GitHub Actions workflows. This can result in an infinite loop. + +If you would like to prevent this, you can add `skip-checks:true` to the commit message. See [Skipping workflow runs](https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs) for details. + ### Change to file is not detected Does your workflow change a file, but "git-auto-commit" does not detect the change? Check the `.gitignore` that applies to the respective file. You might have accidentally marked the file to be ignored by git. From be823a7e51f116fecebc222b8307716921375992 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 08:26:25 +0200 Subject: [PATCH 44/62] Bump github/super-linter from 5 to 6 (#335) Bumps [github/super-linter](https://github.com/github/super-linter) from 5 to 6. - [Release notes](https://github.com/github/super-linter/releases) - [Changelog](https://github.com/github/super-linter/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/super-linter/compare/v5...v6) --- updated-dependencies: - dependency-name: github/super-linter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index e355374d..22009199 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -12,7 +12,7 @@ jobs: uses: actions/checkout@v4 - name: Lint Code Base - uses: github/super-linter@v5 + uses: github/super-linter@v6 env: VALIDATE_ALL_CODEBASE: false VALIDATE_MARKDOWN: false From ac8823709a85c7ce090849ac3e5fe24d006f6e18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 08:16:51 +0200 Subject: [PATCH 45/62] Bump github/super-linter from 6 to 7 (#342) Bumps [github/super-linter](https://github.com/github/super-linter) from 6 to 7. - [Release notes](https://github.com/github/super-linter/releases) - [Changelog](https://github.com/github/super-linter/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/super-linter/compare/v6...v7) --- updated-dependencies: - dependency-name: github/super-linter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 22009199..d994c080 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -12,7 +12,7 @@ jobs: uses: actions/checkout@v4 - name: Lint Code Base - uses: github/super-linter@v6 + uses: github/super-linter@v7 env: VALIDATE_ALL_CODEBASE: false VALIDATE_MARKDOWN: false From e961da7576511032beb0d75de8af56bbce1121b9 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sun, 22 Sep 2024 16:50:21 +0200 Subject: [PATCH 46/62] Update README.md (#343) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 873e2ffc..c88b3560 100644 --- a/README.md +++ b/README.md @@ -433,7 +433,7 @@ please update your Workflow configuration and usage of [`actions/checkout`](http Updating the `token` value with a Personal Access Token should fix your issues. -### git-auto-commit fails to push commit that creates or udpates files in `.github/workflows/` +### git-auto-commit fails to push commit that creates or updates files in `.github/workflows/` The default `GITHUB_TOKEN` issued by GitHub Action does not have permission to make changes to workflow files located in `.github/workflows/`. To fix this, please create a personal access token (PAT) and pass the token to the `actions/checkout`-step in your workflow. (Similar to [how to push to protected branches](https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#push-to-protected-branches)). From 573710f3d0c14b43784ede49b68d484ca7f555dc Mon Sep 17 00:00:00 2001 From: scarf Date: Fri, 4 Oct 2024 15:56:00 +0900 Subject: [PATCH 47/62] docs(README): fix broken protected branch docs link (#346) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c88b3560..114f0066 100644 --- a/README.md +++ b/README.md @@ -444,7 +444,7 @@ See [#322](https://github.com/stefanzweifel/git-auto-commit-action/issues/322) f ### Push to protected branches -If your repository uses [protected branches](https://help.github.com/en/github/administering-a-repository/configuring-protected-branches) you have to make some changes to your Workflow for the Action to work properly: You need a Personal Access Token and you either have to allow force pushes or the Personal Access Token needs to belong to an Administrator. +If your repository uses [protected branches](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches) you have to make some changes to your Workflow for the Action to work properly: You need a Personal Access Token and you either have to allow force pushes or the Personal Access Token needs to belong to an Administrator. First, you have to create a new [Personal Access Token (PAT)](https://github.com/settings/tokens/new), store the token as a secret in your repository and pass the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step. From 050015d40644de3e8d2365687c1fbc235352bcff Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sun, 6 Oct 2024 10:39:09 +0200 Subject: [PATCH 48/62] Add Scope/Permissions documentation for PATs Closes #347 --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 114f0066..0e49f1f1 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,8 @@ storing the token as a secret in your repository and then passing the new token token: ${{ secrets.PAT }} ``` -If you create a personal access token, apply the `repo` and `workflow` scopes. +If you create a personal access token (classic), apply the `repo` and `workflow` scopes. +If you create a fine-grained personal access token, apply the `Contents`-permissions. If you work in an organization and don't want to create a PAT from your personal account, we recommend using a [robot account](https://docs.github.com/en/github/getting-started-with-github/types-of-github-accounts) for the token. @@ -449,6 +450,9 @@ If your repository uses [protected branches](https://docs.github.com/en/reposito First, you have to create a new [Personal Access Token (PAT)](https://github.com/settings/tokens/new), store the token as a secret in your repository and pass the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step. +If you create a personal access token (classic), apply the `repo` and `workflow` scopes. +If you create a fine-grained personal access token, apply the `Contents`-permissions. + ```yaml - uses: actions/checkout@v4 with: From 0b492c0d951b87f3cd12523a542dbd156c1dbc80 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 08:06:23 +0100 Subject: [PATCH 49/62] Bump bats from 1.11.0 to 1.11.1 (#353) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d71dd690..ad49ca30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "bats": "^1.11.0", + "bats": "^1.11.1", "bats-assert": "ztombol/bats-assert", "bats-support": "ztombol/bats-support" }, diff --git a/yarn.lock b/yarn.lock index 65fc8101..125c5245 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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.11.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/bats/-/bats-1.11.0.tgz#40281f021f5befcc10da54ed5674aa5b181f4953" - integrity sha512-qiKdnS4ID3bJ1MaEOKuZe12R4w+t+psJF0ICj+UdkiHBBoObPMHv8xmD3w6F4a5qwUyZUHS+413lxENBNy8xcQ== +bats@^1.11.1: + version "1.11.1" + resolved "https://registry.yarnpkg.com/bats/-/bats-1.11.1.tgz#e87fa1161d5110ec3a685e2e233f2f2bfb26ebfd" + integrity sha512-Dh26FsiLog+wwQeTkboYo2xYj9rUaPEbibUobnYb3G3M9hva/Kby00wrAN9VB9qqGVhl/pYjjt/LVBWwjXlD2A== From 032ffbefae89073f934cf2f508fe68c66a637726 Mon Sep 17 00:00:00 2001 From: Parker Brown <17183625+parkerbxyz@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:38:54 -0800 Subject: [PATCH 50/62] Include `github.actor_id` in default `commit_author` This mimics the default commit author used by GitHub and matches the format used for the default `commit_user_email`. --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 8192c950..fe8bfb36 100644 --- a/action.yml +++ b/action.yml @@ -43,7 +43,7 @@ inputs: commit_author: description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run. required: false - default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + default: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> tagging_message: description: Message used to create a new git tag with the commit. Keep this empty, if no tag should be created. required: false From e35726034b3ecce33707aab96909aed0a404d55c Mon Sep 17 00:00:00 2001 From: stefanzweifel Date: Sat, 11 Jan 2025 07:12:19 +0000 Subject: [PATCH 51/62] Update CHANGELOG --- CHANGELOG.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fcbddf6..cb8f4362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,27 @@ 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/v5.0.1...HEAD) +## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.1.0...HEAD) > TBD +## [v5.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.1...v5.1.0) - 2025-01-11 + +### Changed + +- Include `github.actor_id` in default `commit_author` ([#354](https://github.com/stefanzweifel/git-auto-commit-action/pull/354)) [@parkerbxyz](https://github.com/@parkerbxyz) + +### Fixed + +- docs(README): fix broken protected branch docs link ([#346](https://github.com/stefanzweifel/git-auto-commit-action/pull/346)) [@scarf005](https://github.com/@scarf005) +- Update README.md ([#343](https://github.com/stefanzweifel/git-auto-commit-action/pull/343)) [@Kludex](https://github.com/@Kludex) + +### Dependency Updates + +- Bump bats from 1.11.0 to 1.11.1 ([#353](https://github.com/stefanzweifel/git-auto-commit-action/pull/353)) [@dependabot](https://github.com/@dependabot) +- Bump github/super-linter from 6 to 7 ([#342](https://github.com/stefanzweifel/git-auto-commit-action/pull/342)) [@dependabot](https://github.com/@dependabot) +- Bump github/super-linter from 5 to 6 ([#335](https://github.com/stefanzweifel/git-auto-commit-action/pull/335)) [@dependabot](https://github.com/@dependabot) + ## [v5.0.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.0...v5.0.1) - 2024-04-12 ### Fixed From c86fa26bedab90b9a250e22f66759c0c50699f15 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2025 13:54:04 +0100 Subject: [PATCH 52/62] Replace Yarn with NPM --- package-lock.json | 35 +++++++++++++++++++++++++++++++++++ yarn.lock | 16 ---------------- 2 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 package-lock.json delete mode 100644 yarn.lock diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..38b34a5e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,35 @@ +{ + "name": "git-auto-commit-action", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "bats": "^1.11.1", + "bats-assert": "ztombol/bats-assert", + "bats-support": "ztombol/bats-support" + } + }, + "node_modules/bats": { + "version": "1.11.1", + "dev": true, + "license": "MIT", + "bin": { + "bats": "bin/bats" + } + }, + "node_modules/bats-assert": { + "version": "0.3.0", + "resolved": "git+ssh://git@github.com/ztombol/bats-assert.git#9f88b4207da750093baabc4e3f41bf68f0dd3630", + "dev": true, + "peerDependencies": { + "bats-support": "git+https://github.com/ztombol/bats-support.git#v0.2.0" + } + }, + "node_modules/bats-support": { + "version": "0.3.0", + "resolved": "git+ssh://git@github.com/ztombol/bats-support.git#004e707638eedd62e0481e8cdc9223ad471f12ee", + "dev": true + } + } +} diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index 125c5245..00000000 --- a/yarn.lock +++ /dev/null @@ -1,16 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -bats-assert@ztombol/bats-assert: - version "0.3.0" - resolved "https://codeload.github.com/ztombol/bats-assert/tar.gz/9f88b4207da750093baabc4e3f41bf68f0dd3630" - -bats-support@ztombol/bats-support: - version "0.3.0" - resolved "https://codeload.github.com/ztombol/bats-support/tar.gz/004e707638eedd62e0481e8cdc9223ad471f12ee" - -bats@^1.11.1: - version "1.11.1" - resolved "https://registry.yarnpkg.com/bats/-/bats-1.11.1.tgz#e87fa1161d5110ec3a685e2e233f2f2bfb26ebfd" - integrity sha512-Dh26FsiLog+wwQeTkboYo2xYj9rUaPEbibUobnYb3G3M9hva/Kby00wrAN9VB9qqGVhl/pYjjt/LVBWwjXlD2A== From 8a23be4b32ffb90ffb63e74b5063134bced62d01 Mon Sep 17 00:00:00 2001 From: Ross Smith II Date: Thu, 13 Mar 2025 08:29:02 -0700 Subject: [PATCH 53/62] docs: Update README.md per #354 See #354 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e49f1f1..f2c909e7 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ The following is an extended example with all available options. # Optional commit user and author settings commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]" commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com" - commit_author: Author # defaults to "username ", where "username" belongs to the author of the commit that triggered the run + commit_author: Author # defaults to "username ", where "numeric_id" and "username" belong to the author of the commit that triggered the run # Optional. Tag name being created in the local repository and # pushed to remote repository and defined branch. From 4db797a96155206d562625b4ad7a08dca23f1bf4 Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:01:31 +0200 Subject: [PATCH 54/62] Update entrypoint.sh --- entrypoint.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index bff98e0e..03931e70 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,8 +30,12 @@ _main() { _check_if_git_is_available _switch_to_repository - - if _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then + if _git_tag_only; then + _log "debug" "git tag only."; + _set_github_output "git_tag_only" "true" + _tag_commit + _push_to_github + elif _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then _set_github_output "changes_detected" "true" From 2ac10431a86a5b997e9573eb6c9651f2382a437a Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:02:49 +0200 Subject: [PATCH 55/62] Update action.yml --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index fe8bfb36..2b8ea386 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,10 @@ description: 'Automatically commits files which have been changed during the wor author: Stefan Zweifel inputs: + git_tag_only: + description: Perform a clean git tag and push, without commiting anything + required: false + default: false commit_message: description: Commit message required: false From 12e100dacb907a92e0dc82346eaf871f83e7847a Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:05:01 +0200 Subject: [PATCH 56/62] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 03931e70..ee261463 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,7 +30,7 @@ _main() { _check_if_git_is_available _switch_to_repository - if _git_tag_only; then + if "$INPUT_GIT_TAG_ONLY"; then _log "debug" "git tag only."; _set_github_output "git_tag_only" "true" _tag_commit From 19379b46c9475e7b57e9a487de999197e859098a Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:05:21 +0200 Subject: [PATCH 57/62] Update git-auto-commit.bats --- tests/git-auto-commit.bats | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index d08597cc..43e2c149 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -21,6 +21,7 @@ setup() { export FAKE_DEFAULT_BRANCH=$(git config init.defaultBranch) # Set default INPUT variables used by the GitHub Action + export INPUT_GIT_TAG_ONLY=true export INPUT_REPOSITORY="${FAKE_LOCAL_REPOSITORY}" export INPUT_COMMIT_MESSAGE="Commit Message" export INPUT_BRANCH="${FAKE_DEFAULT_BRANCH}" From cfd6ac4a3bab2e8adaa26e0374379af334adfc43 Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:14:41 +0200 Subject: [PATCH 58/62] Update git-auto-commit.bats --- tests/git-auto-commit.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index 43e2c149..26f6de3d 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -21,7 +21,7 @@ setup() { export FAKE_DEFAULT_BRANCH=$(git config init.defaultBranch) # Set default INPUT variables used by the GitHub Action - export INPUT_GIT_TAG_ONLY=true + export INPUT_GIT_TAG_ONLY=false export INPUT_REPOSITORY="${FAKE_LOCAL_REPOSITORY}" export INPUT_COMMIT_MESSAGE="Commit Message" export INPUT_BRANCH="${FAKE_DEFAULT_BRANCH}" From 35d037abf5810698ff3d047321be58dda3323986 Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:33:45 +0200 Subject: [PATCH 59/62] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index f2c909e7..5eef900e 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,10 @@ The following is an extended example with all available options. ```yaml - uses: stefanzweifel/git-auto-commit-action@v5 with: + # Perform a clean git tag and push, without commiting anything + # Default to false + git_tag_only: false + # Optional. Commit message for the created commit. # Defaults to "Apply automatic changes" commit_message: Automated Change From 4f8f3ad16ec3c524651ccc9ca4eb5f40cec44525 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 19 Apr 2025 09:38:21 +0200 Subject: [PATCH 60/62] Rename Input and add output --- README.md | 8 ++++---- action.yml | 10 ++++++---- entrypoint.sh | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5eef900e..60071bb4 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,6 @@ The following is an extended example with all available options. ```yaml - uses: stefanzweifel/git-auto-commit-action@v5 with: - # Perform a clean git tag and push, without commiting anything - # Default to false - git_tag_only: false - # Optional. Commit message for the created commit. # Defaults to "Apply automatic changes" commit_message: Automated Change @@ -122,6 +118,10 @@ The following is an extended example with all available options. # Optional. Create given branch name in local and remote repository. create_branch: true + + # Perform a clean git tag and push, without commiting anything + # Default to false + create_git_tag_only: false ``` Please note that the Action depends on `bash`. If you're using the Action in a job in combination with a custom Docker container, make sure that `bash` is installed. diff --git a/action.yml b/action.yml index 2b8ea386..caf82374 100644 --- a/action.yml +++ b/action.yml @@ -4,10 +4,6 @@ description: 'Automatically commits files which have been changed during the wor author: Stefan Zweifel inputs: - git_tag_only: - description: Perform a clean git tag and push, without commiting anything - required: false - default: false commit_message: description: Commit message required: false @@ -74,6 +70,10 @@ 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 + create_git_tag_only: + description: Perform a clean git tag and push, without commiting anything + required: false + 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 @@ -83,6 +83,8 @@ outputs: description: Value is "true", if the repository was dirty and file changes have been detected. Value is "false", if no changes have been detected. commit_hash: description: Full hash of the created commit. Only present if the "changes_detected" output is "true". + create_git_tag_only: + description: runs: using: 'node20' diff --git a/entrypoint.sh b/entrypoint.sh index ee261463..22098dfc 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,9 +30,9 @@ _main() { _check_if_git_is_available _switch_to_repository - if "$INPUT_GIT_TAG_ONLY"; then - _log "debug" "git tag only."; - _set_github_output "git_tag_only" "true" + if "$INPUT_CREATE_GIT_TAG_ONLY"; then + _log "debug" "Create git tag only"; + _set_github_output "create_git_tag_only" "true" _tag_commit _push_to_github elif _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then From 8480c68cbb7b1813d49aecb1164b935d6a72b726 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 19 Apr 2025 10:17:54 +0200 Subject: [PATCH 61/62] Add Tests --- tests/git-auto-commit.bats | 53 +++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index 26f6de3d..f1fb4b8e 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -21,7 +21,7 @@ setup() { export FAKE_DEFAULT_BRANCH=$(git config init.defaultBranch) # Set default INPUT variables used by the GitHub Action - export INPUT_GIT_TAG_ONLY=false + export INPUT_CREATE_GIT_TAG_ONLY=false export INPUT_REPOSITORY="${FAKE_LOCAL_REPOSITORY}" export INPUT_COMMIT_MESSAGE="Commit Message" export INPUT_BRANCH="${FAKE_DEFAULT_BRANCH}" @@ -1126,3 +1126,54 @@ END assert_failure; assert_line "::error::git-status failed with:" } + +@test "it creates a tag if create_git_tag_only is set to true and a message has been supplied" { + INPUT_CREATE_GIT_TAG_ONLY=true + INPUT_TAGGING_MESSAGE=v1.0.0 + + run git_auto_commit + + assert_success + + assert_line "::debug::Create git tag only" + + assert_line "::debug::Create tag v1.0.0" + refute_line "No tagging message supplied. No tag will be added." + + assert_line "::debug::Apply push options " + assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}" + + run cat_github_output + assert_line "create_git_tag_only=true" + refute_line "changes_detected=false" + refute_line -e "commit_hash=[0-9a-f]{40}$" + + # Assert a tag v1.0.0 has been created + run git tag + assert_output v1.0.0 + + run git ls-remote --tags --refs + assert_output --partial refs/tags/v1.0.0 +} + +@test "it output no tagging message supplied if no tagging message is set but create_git_tag_only is set to true" { + INPUT_CREATE_GIT_TAG_ONLY=true + INPUT_TAGGING_MESSAGE="" + + run git_auto_commit + + assert_success + + assert_line "INPUT_TAGGING_MESSAGE: " + assert_line "No tagging message supplied. No tag will be added." + assert_line "::debug::Create git tag only" + + run cat_github_output + assert_line "create_git_tag_only=true" + refute_line "changes_detected=false" + refute_line -e "commit_hash=[0-9a-f]{40}$" + + # Assert no tag has been created + run git tag + assert_output "" +} From adb37b5a29cc6a129145d9d032185cb98f85158c Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 19 Apr 2025 10:32:21 +0200 Subject: [PATCH 62/62] Update README --- README.md | 5 +++-- action.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 60071bb4..4e9b3193 100644 --- a/README.md +++ b/README.md @@ -119,8 +119,8 @@ The following is an extended example with all available options. # Optional. Create given branch name in local and remote repository. create_branch: true - # Perform a clean git tag and push, without commiting anything - # Default to false + # Optional. Creates a new tag and pushes it to remote without creating a commit. + # Skips dirty check and changed files. Must be used with `tagging_message`. create_git_tag_only: false ``` @@ -173,6 +173,7 @@ You can use these outputs to trigger other Actions in your Workflow run based on - `changes_detected`: Returns either "true" or "false" if the repository was dirty and files have changed. - `commit_hash`: Returns the full hash of the commit if one was created. +- `create_git_tag_only`: Returns either "true" or "false" if a tag was created, when `create_git_tag_only` was used. **⚠️ When using outputs, the step needs to be given an id. See example below.** diff --git a/action.yml b/action.yml index caf82374..c57a5088 100644 --- a/action.yml +++ b/action.yml @@ -84,7 +84,7 @@ outputs: commit_hash: description: Full hash of the created commit. Only present if the "changes_detected" output is "true". create_git_tag_only: - description: + description: Value is "true", if a git tag was created using the `create_git_tag_only`-input. runs: using: 'node20'