stefanzweifel/git-auto-commit-action

GitHub: stefanzweifel/git-auto-commit-action

一个轻量级 GitHub Action,用于在 CI 工作流中自动检测已更改的文件并将其提交推送回远程仓库。

Stars: 2559 | Forks: 285

# git-auto-commit Action 一个 GitHub Action,用于在 Workflow 运行期间检测已更改的文件,并将它们提交和推送回 GitHub 仓库。 默认情况下,提交以“GitHub Actions”的名义进行,并由最后一次提交的用户共同创作。 如果您想进一步了解此 Action 在底层的运作方式,请阅读 Michael Heap 的[这篇文章](https://michaelheap.com/git-auto-commit/)。 如果您的使用场景未被 git-auto-commit 涵盖,您可能需要查看以下替代 Action: - [planetscale/ghcommit-action](https://github.com/planetscale/ghcommit-action) - [EndBug/add-and-commit](https://github.com/EndBug/add-and-commit) ## 用法 将 git-auto-commit 添加到您的 Workflow 只需要几行代码。 1. 将默认 GITHUB_TOKEN 的 `contents` 权限设置为 `write`。(这是将新提交推送到仓库所必需的) 2. 在作业末尾,即其他可能添加或更改文件的步骤之后,添加以下步骤。 ``` - uses: stefanzweifel/git-auto-commit-action@v7 ``` 您的 Workflow 看起来应该与此示例类似。 ``` name: Format on: push jobs: format-code: runs-on: ubuntu-latest permissions: # Give the default GITHUB_TOKEN write permission to commit and push the # added or changed files to the repository. contents: write steps: - uses: actions/checkout@v5 with: ref: ${{ github.head_ref }} # Value already defaults to true, but `persist-credentials` is required to push new commits to the repository. persist-credentials: true # Other steps that change files in the repository go here # … # Commit all changed files back to the repository - uses: stefanzweifel/git-auto-commit-action@v7 ``` 以下是包含所有可用选项的扩展示例。 ``` - uses: stefanzweifel/git-auto-commit-action@v7 with: # Optional. Commit message for the created commit. # Defaults to "Apply automatic changes" commit_message: Automated Change # Optional. Remote branch name where commit is going to be pushed to. # Defaults to the current branch. branch: feature-123 # Optional. Options used by `git-commit`. # See https://git-scm.com/docs/git-commit#_options commit_options: '--no-verify --signoff' # Optional glob pattern of files which should be added to the commit # Defaults to all (.) # See the `pathspec`-documentation for git # - https://git-scm.com/docs/git-add#Documentation/git-add.txt-ltpathspecgt82308203 # - https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec file_pattern: '*.php src/*.js tests/*.js' # Optional. Relative file path under $GITHUB_WORKSPACE to the repository. # Defaults to the root of the repository. repository: . # 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 "numeric_id" and "username" belong to the author of the commit that triggered the run # Optional. Tag name to be created in the local repository and # pushed to the remote repository on the defined branch. # If only one of `tag_name` or `tagging_message` is provided, the value of the provided field will be used for both tag name and message. tag_name: 'v1.0.0' # Optional. Message to annotate the created tag with. # If only one of `tag_name` or `tagging_message` is provided, the value of the provided field will be used for both tag name and message. tagging_message: 'Codename "Sunshine"' # Optional. Option used by `git-status` to determine if the repository is # dirty. See https://git-scm.com/docs/git-status#_options status_options: '--untracked-files=no' # Optional. Options used by `git-add`. # See https://git-scm.com/docs/git-add#_options add_options: '-u' # Optional. Options used by `git-push`. # See https://git-scm.com/docs/git-push#_options push_options: '--force' # Optional. Disable dirty check and always try to create a commit and push skip_dirty_check: true # Optional. Skip internal call to `git fetch` skip_fetch: true # Optional. Skip internal call to `git checkout` skip_checkout: true # Optional. Skip internal call to `git push` skip_push: true # Optional. Prevents the shell from expanding filenames. # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html disable_globbing: true # Optional. Create given branch name in local and remote repository. create_branch: true # Optional. Creates a new tag and pushes it to remote without creating a commit. # Skips dirty check and changed files. Must be used in combination with `tag` and `tagging_message`. create_git_tag_only: false # Optional. Suppress the security warning emitted when the action runs on a # `pull_request_target` event. See the "Workflow should run in **base** repository" # section below for context before disabling this warning. disable_pull_request_target_trigger_warning: false # Optional. Shell snippets to run around each git operation. Each hook # is evaluated in the same bash process as the action — `set -eu` is # in effect, the working directory is your repository, and all # `INPUT_*` env vars are visible. A non-zero exit aborts the action. before_add_hook: '' after_add_hook: '' before_commit_hook: '' after_commit_hook: '' before_tag_hook: '' after_tag_hook: '' before_push_hook: '' after_push_hook: '' ``` 请注意,此 Action 依赖于 `bash`。如果您在作业中结合自定义 Docker 容器使用此 Action,请确保已安装 `bash`。 ## Workflow 示例 在此示例中,我们在 PHP 项目中运行 `php-cs-fixer` 以自动修复代码风格,然后将可能更改的文件提交回仓库。 请注意,我们在 checkout Action 中显式指定了 `${{ github.head_ref }}`。 这是为了能够处理 `pull_request` 事件(或任何其他非 `push` 事件)所必需的。 ``` name: php-cs-fixer on: pull_request: push: branches: - main 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@v5 with: ref: ${{ github.head_ref }} - name: Run php-cs-fixer uses: docker://oskarstark/php-cs-fixer-ga - uses: stefanzweifel/git-auto-commit-action@v7 with: commit_message: Apply php-cs-fixer changes ``` 请查看 [EXAMPLES.md](EXAMPLES.md) 了解更多场景,包括自动格式化、依赖更新、生成文档、发布标签、偏差检查以及 GPG 签名的提交。 ## 输入 查看 [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/action.yml) 获取受支持输入的完整列表。 ## 输出 您可以在 Workflow 运行中,基于 `git-auto-commit-action` 的结果使用这些输出来触发其他 Action。 - `changes_detected`:如果仓库发生变动且文件有更改,返回“true”或“false”。 - `commit_hash`:如果创建了提交,则返回该提交的完整哈希值。 - `commit_hash`:如果在使用了 `create_git_tag_only` 的情况下创建了标签,则返回“true”或“false”。 **⚠️ 使用输出时,必须为该步骤指定一个 id。请参见以下示例。** ### 示例 ``` - uses: stefanzweifel/git-auto-commit-action@v7 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!" - name: "Run if no changes have been detected" if: steps.auto-commit-action.outputs.changes_detected == 'false' run: echo "No Changes!" ``` ## Hooks git-auto-commit 可以在它执行的每个 git 操作前后运行自定义 shell 代码片段。当您需要在同一步骤中准备或清理仓库时,这非常有用——例如,在暂存提交之前将浅克隆转换为非浅克隆。 共有八个可选的 hook: | Hook | 运行时机 | | ---- | ---- | | `before_add_hook` / `after_add_hook` | `git add` 前后 | | `before_commit_hook` / `after_commit_hook` | `git commit` 前后 | | `before_tag_hook` / `after_tag_hook` | `git tag` 前后(仅在创建标签时) | | `before_push_hook` / `after_push_hook` | `git push` 前后(当 `skip_push: true` 时跳过) | 每个 hook 都是一个内联 shell 片段,在与 action 相同的 bash 进程中运行。工作目录是您的仓库,并且所有 `INPUT_*` 环境变量和标准 GitHub Actions 环境变量对该片段都是可见的。 ### 示例 ``` - uses: stefanzweifel/git-auto-commit-action@v7 with: before_add_hook: | git fetch --unshallow ``` 多行片段可以通过 YAML 的 `|` 块标量来实现: ``` - uses: stefanzweifel/git-auto-commit-action@v7 with: before_commit_hook: | echo "About to commit at $(date)" ./scripts/prepare-commit.sh ``` ### 注意事项 - Hook 仅在其底层步骤实际运行时才会执行。例如,当工作树是干净的时,`before_add_hook`/`after_add_hook` 将被跳过;当 `skip_push: true` 时,`before_push_hook`/`after_push_hook` 将被跳过。 - 如果 hook 以非零状态退出,action 将失败。可以在片段末尾追加 `|| true` 来忽略其失败。 - Hook 与 action 共享环境,因此它们可以读取 action 的输入(例如 `$INPUT_COMMIT_MESSAGE`)并写入 `$GITHUB_OUTPUT`。 - 片段在 `set -eu` 下运行。引用未设置的变量将中止 action;请使用 `${VAR:-}` 将可选变量默认设置为空。 ### 安全性 Hook 片段作为 shell 代码在与 action 相同的进程中进行评估。请像对待任何 `run:` 步骤一样对待它们。 如果您需要在 hook 中使用来自 PR 控制上下文的值,请通过中间环境变量传递它们,而不是直接将它们插入到片段中: ``` - uses: stefanzweifel/git-auto-commit-action@v7 env: PR_TITLE: ${{ github.event.pull_request.title }} with: before_commit_hook: | # $PR_TITLE is read as data, not evaluated as code echo "PR: $PR_TITLE" ``` ## 限制与注意事项 此 Action 的目标是成为“满足 80% 使用场景的文件提交 Action”。因此,如果您的 Workflow 属于那未被支持的 20%,您可能会遇到问题。 以下是该 Action 明确不支持的一些边缘情况列表: **当仓库与远程不同步时,不执行 `git pull`。** 此 Action 在执行 `git push` 之前不会执行 `git pull`。**您**有责任在 Workflow 运行中保持仓库是最新的。 **不支持在构建矩阵 中运行此 Action**。如果您的 Workflow 使用了构建矩阵,并且希望每个作业都提交并推送文件到远程,您将会遇到 Workflow 中的仓库过时的问题。由于此 Action 不会为您执行 `git pull`,因此您必须自己执行。 **不支持 `git rebase` 或 `git merge`**。关于如何将远程上游更改集成到本地仓库,有许多策略。`git-auto-commit` 不希望承担执行此操作的责任。 **不支持检测 CR(回车符)和 LF(换行符)之间的换行符更改**。这是一个底层问题,您必须在项目中以其他方式解决。非常抱歉。 如果此 Action 不适用于您的工作流,请查看 [EndBug/add-and-commit](https://github.com/EndBug/add-and-commit)。 ### 检出正确的分支 您必须使用 `actions/checkout@v2` 或更高版本来检出仓库。 在非 `push` 事件(例如 `pull_request`)中,请确保指定要检出的 `ref`: ``` - uses: actions/checkout@v5 with: ref: ${{ github.head_ref }} ``` 这样做是为了避免在分离状态下检出仓库。 ### 此 Action 进行的提交不会触发新的 Workflow 运行 生成的提交**不会触发**另一个 GitHub Actions Workflow 运行。 这是由于 [GitHub 设置的限制](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow)。 您可以通过创建一个新的 [Personal Access Token (PAT)](https://github.com/settings/tokens/new)、将该 token 作为 secret 存储在您的仓库中,然后将新 token 传递给 [`actions/checkout`](https://github.com/actions/checkout#usage) Action 步骤来更改此设置。 ``` - uses: actions/checkout@v5 with: token: ${{ secrets.PAT }} ``` 如果您创建的是 personal access token (classic),请应用 `repo` 和 `workflow` 作用域。 如果您创建的是 fine-grained personal access token,请应用 `Contents` 权限。 如果您在组织中工作,并且不想从您的个人账户创建 PAT,我们建议使用 [机器人账户](https://docs.github.com/en/get-started/learning-about-github/types-of-github-accounts) 来提供 token。 ### 使用 Personal Access Token 时防止无限循环 如果您使用 Personal Access Token (PAT) 将提交推送到 GitHub 仓库,生成的提交或推送可能会触发其他 GitHub Actions 工作流。这可能会导致无限循环。 如果您想防止这种情况,可以在提交消息中添加 `skip-checks:true`。详情请参阅[跳过工作流运行](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/skip-workflow-runs)。 ### 文件的更改未被检测到 您的工作流是否更改了文件,但“git-auto-commit”未检测到更改?请检查适用于该文件的 `.gitignore`。您可能无意中将该文件标记为被 git 忽略了。 ## 高级用法 ### 多行提交信息 如果您的提交信息需要跨越多行,您必须创建一个单独的步骤来生成该字符串。 下面的示例可以作为生成多行提交信息的起点。请在 [GitHub 文档](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#multiline-strings)中了解更多关于 GitHub Actions 中多行字符串的工作原理。 ``` # 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@v7 id: commit with: commit_message: ${{ steps.commit_message_step.outputs.commit_message }} ``` ### 签名提交 如果您想使用 GPG key 对提交进行签名,您将需要使用额外的 action。 您可以使用 [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) action 并按照其设置说明进行操作。 由于 git-auto-commit 在创建提交时默认**不**使用**您的**用户名和电子邮件,您必须在您的工作流中覆盖这些值。 ``` - 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@v7 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 }} ``` 详情请参见讨论 [#334](https://github.com/stefanzweifel/git-auto-commit-action/discussions/334)。 ### 在私有仓库的 fork 中使用 默认情况下,GitHub Actions 不会在**私有**仓库的 fork 上运行 Workflow。要为**私有**仓库启用 Actions,请在您的仓库设置中启用“Run workflows from pull requests”。 详情请参阅 [GitHub 的此公告](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/)或 [GitHub 文档](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#enabling-workflows-for-private-repository-forks)。 ### 在公有仓库的 fork 中使用 默认情况下,此 Action 不会在由 fork 打开的 Pull Request 上运行。(这是 GitHub 的限制,而不是我们的限制。) 然而,有几种方法可以在需要由 fork 仓库触发的工作流中使用此 Action。 ### 工作流应在 **base**(基础)仓库中运行 下面的工作流通过监听 [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) 事件,在提交被推送到 `main` 分支或 pull request 上有活动时运行。 如果工作流由 `pull_request_target` 事件触发,工作流将在 pull request 基础分支的上下文中运行,而不是像 `pull_request` 事件那样在合并提交的上下文中运行。 换句话说,这将允许您的工作流在打开 pull request 的目标仓库中运行,并将更改推送回 fork。 查看 [#211](https://github.com/stefanzweifel/git-auto-commit-action/issues/211) 中的讨论以获取有关此内容的更多信息。 ``` name: Format PHP on: push: branches: - main pull_request_target: jobs: php-cs-fixer: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v5 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 uses: docker://oskarstark/php-cs-fixer-ga - uses: stefanzweifel/git-auto-commit-action@v7 ``` 有关在 fork 上运行 Actions 的更多信息,请参见[GitHub 的此公告](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/)。 ### 使用 `--amend` 和 `--no-edit` 作为提交选项 如果您想使用此 Action 通过 [`--amend`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend) 和 [`--no-edit`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-edit) 创建提交,您需要进行一些调整。 首先,您需要使用 `git log -1 --pretty=%s` 提取上一次的提交信息。 然后,您需要通过 `commit_message` 输入选项将此最后一条提交信息提供给 Action。 默认情况下,提交作者会被更改为 `username `,其中 `username` 是触发工作流的用户名(此处使用了 [`github.actor`](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context) 上下文)。如果您想保留原始作者的姓名和电子邮件,您必须从最后一次提交中提取它们,并通过 `commit_author` 输入选项提供给 Action。 最后,您必须使用 `push_options: '--force'` 来覆盖 GitHub 远程仓库上的 git 历史记录。(git-auto-commit 不会为您执行 `git-rebase`!) 您工作流中的步骤可能如下所示: ``` - uses: actions/checkout@v4 with: # Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history) fetch-depth: 2 # 工作流中的其他步骤以触发已更改的文件 - name: Get last commit message id: last-commit run: | 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@v7 with: 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 ``` 详情请参见 [#159](https://github.com/stefanzweifel/git-auto-commit-action/issues/159#issuecomment-845347950) 中的讨论。 ## 故障排除 ### Action 未将提交推送到仓库 确保[检出正确的分支](#checkout-the-correct-branch)。 ### Action 未将提交推送到仓库:身份验证问题 如果您的 Workflow 由于身份验证问题无法将提交推送到仓库, 请更新您的工作流配置和 [`actions/checkout`](https://github.com/actions/checkout#usage) 的使用。 请注意,`actions/checkout` 中的 `persist-credentials` 必须设置为 `true` 才能将新提交推送到仓库。 如果您仍然无法推送提交,并且您正在使用分支保护规则或类似功能,使用 Personal Access Token 更新 `token` 值应该可以解决您的问题。 ### git-auto-commit 无法推送在 `.github/workflows/` 中创建或更新文件的提交 GitHub Action 颁发的默认 `GITHUB_TOKEN` 没有权限对 `.github/workflows/` 中的工作流文件进行更改。 要解决此问题,请创建一个 personal access token (PAT),并在您的工作流中将该 token 传递给 `actions/checkout` 步骤。(类似于[如何推送到受保护分支](https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#push-to-protected-branches))。 如果 PAT 对您不起作用,您也可以创建一个新的 GitHub app 并在其工作流中使用其 token。详情请参见 [#87 中的此评论](https://github.com/stefanzweifel/git-auto-commit-action/issues/87#issuecomment-1939138661)。 有关此主题的详细信息和讨论,请参见 [#322](https://github.com/stefanzweifel/git-auto-commit-action/issues/322)。 ### 推送到受保护分支 如果您的仓库使用了[受保护分支](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches),您必须对工作流进行一些更改才能使 Action 正常工作:您需要一个 Personal Access Token,并且您必须允许强制推送,或者该 Personal Access Token 必须属于管理员。 首先,您必须创建一个新的 [Personal Access Token (PAT)](https://github.com/settings/tokens/new), 将该 token 作为 secret 存储在您的仓库中,并将新 token 传递给 [`actions/checkout`](https://github.com/actions/checkout#usage) Action 步骤。 如果您创建的是 personal access token (classic),请应用 `repo` 和 `workflow` 作用域。 如果您创建的是 fine-grained personal access token,请应用 `Contents` 权限。 ``` - uses: actions/checkout@v5 with: # We pass the "PAT" secret to the checkout action; if no PAT secret is available to the workflow runner (eg. Dependabot) we fall back to the default "GITHUB_TOKEN". token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} ``` 您可以在 [GitHub 文档https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)中了解更多关于 Personal Access Token 的信息。 如果您选择走“强制推送”这条路,您必须启用对受保护分支的强制推送(参见[文档](https://docs.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)),并更新您的工作流以使用强制推送,如下所示。 ``` - uses: stefanzweifel/git-auto-commit-action@v7 with: commit_message: Apply php-cs-fixer changes push_options: --force ``` ### 此 Action 的提交未触发新的工作流 这是由于 GitHub 设置的限制,[此 Action 进行的提交不会触发新的 Workflow 运行](#commits-made-by-this-action-do-not-trigger-new-workflow-runs)。 ### Pathspec 'x' 未匹配任何文件 如果您在将此 Action 与自定义 `file_pattern` 结合使用时,Action 抛出致命错误并提示“Pathspec 'file-pattern' did not match any files”,问题很可能是仓库中**存在**该模式对应的文件。 `file_pattern` 在此 Action 中同时用于 `git-status` 和 `git-add`。例如,如果您使用了类似 `*.js *.ts` 的文件模式,但您的项目仓库中不存在任何 `*.ts` 文件,`git-add` 将抛出致命错误。 详情请参见 [Issue #227](https://github.com/stefanzweifel/git-auto-commit-action/issues/227)。 ### 使用自定义 `file_pattern`,更改了文件但在日志中看到“Working tree clean. Nothing to commit.” 如果您使用了自定义 `file_pattern`,但 Action 未检测到您在工作流中所做的更改,您可能遇到了 globbing(通配符展开)问题。 假设您使用 `file_pattern: '*.md'` 来检测并提交仓库中所有 Markdown 文件的更改。 如果您的 Workflow 现在仅更新了子目录中的 `.md` 文件,但您在仓库根目录下有一个未修改的 `.md` 文件,git-auto-commit Action 将在工作流日志中显示“Working tree clean. Nothing to commit.”。 这是因为 `*.md` 通配符在发送给 `git-status` 之前就被展开了。`git-status` 将接收到您仓库根目录下那个未修改的 `.md` 文件的文件名,并且不会检测到任何更改;因此 Action 什么也不做。 要解决此问题,请将 `disable_globbing: true` 添加到您的工作流中。 ``` - uses: stefanzweifel/git-auto-commit-action@v7 with: file_pattern: '*.md' disable_globbing: true ``` 详情请参见 [Issue #239](https://github.com/stefanzweifel/git-auto-commit-action/issues/239)。 ## 运行测试 此 Action 包含使用 [bats](https://github.com/bats-core/bats-core) 编写的测试。在本地运行测试套件之前,您必须使用 `npm` 或 `yarn` 安装依赖项。 ``` npm install yarn ``` 您可以使用 `npm` 或 `yarn` 运行测试套件。 ``` npm run test yarn test ``` ## 版本控制 我们使用 [SemVer](https://semver.org/) 进行版本控制。对于可用的版本,请查看[此仓库的标签](https://github.com/stefanzweifel/git-auto-commit-action/tags)。 我们还提供主版本标签,以便更轻松地始终使用某个主版本的最新发布版。例如,您可以使用 `stefanzweifel/git-auto-commit-action@v7` 来始终使用当前主版本的最新发布版。 (有关此内容的更多信息请参见[这里](https://docs.github.com/en/actions/building-actions/about-actions#versioning-your-action))。 ## 致谢 * [Stefan Zweifel](https://github.com/stefanzweifel) * [所有贡献者](https://github.com/stefanzweifel/git-auto-commit-action/graphs/contributors) 此 Action 受到加拿大数字服务局的 [auto-commit](https://github.com/cds-snc/github-actions/tree/master/auto-commit )-Action 的启发和改编,同时也参考了 Eric Johnson 的这个 [commit](https://github.com/elstudio/actions-js-build/blob/41d604d6e73d632e22eac40df8cc69b5added04b/commit/entrypoint.sh)-Action。 ## 许可证 该项目基于 MIT 许可证授权 - 有关详细信息,请参阅 [LICENSE](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/LICENSE) 文件。
标签:Git, GitHub Actions, SOC Prime, 应用安全, 开发工具, 网络安全研究, 网络调试, 自动化, 自动笔记