From 8a65534aa8495a0a2b3320194f720a64029367a3 Mon Sep 17 00:00:00 2001 From: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:50:25 +0900 Subject: [PATCH] =?UTF-8?q?git=20commit,=20push=E6=99=82=E3=81=AB--no-veri?= =?UTF-8?q?fy=E3=82=92=E4=BB=98=E4=B8=8E=E3=81=99=E3=82=8B=E3=82=AA?= =?UTF-8?q?=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E8=BF=BD=E5=8A=A0=20(#1430?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * git commit, push時に--no-verifyを付与するオプション追加 * コマンド修正 * README修正 (#1431) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * 元のgit commit削除 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- README.md | 1 + action.yml | 5 +++++ scripts/action/push.sh | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5f389a1d9..9d7057afa 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ jobs: | pr-description-prefix | 本文の接頭語。 | | | | exit-failure | 実行完了時にCIを失敗させるかどうか。 | | true | | working-directory | 実行対象のディレクトリ | | | +| no-verify | git commit, push時のフックを無効化する | | false | ## 対応しているトリガー * pull_request diff --git a/action.yml b/action.yml index 3a8a26e15..3cf10e4f6 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,10 @@ inputs: description: '実行対象のディレクトリ' required: false default: "" + no-verify: + description: 'git commit, push時のフックを無効化する' + required: false + default: "false" runs: using: "composite" steps: @@ -46,6 +50,7 @@ runs: TOKEN: ${{inputs.github-token}} REPOSITORY: ${{github.repository}} BRANCH_NAME_PREFIX: ${{inputs.branch-name-prefix}} + NO_VERIFY: ${{inputs.no-verify}} if: steps.diff.outputs.result != '' && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch') working-directory: ${{inputs.working-directory}} run: ${{ github.action_path }}/scripts/action/push.sh diff --git a/scripts/action/push.sh b/scripts/action/push.sh index f56618ec4..7da9c3cbd 100755 --- a/scripts/action/push.sh +++ b/scripts/action/push.sh @@ -3,9 +3,23 @@ git config user.name "github-actions[bot]" EMAIL="41898282+github-actions[bot]@users.noreply.github.com" git config user.email "${EMAIL}" -git commit -m "${PR_TITLE_PREFIX}" +GIT_COMMIT_COMMAND="git commit" + +if [ "$NO_VERIFY" = "true" ]; then + GIT_COMMIT_COMMAND="$GIT_COMMIT_COMMAND --no-verify" +fi + +GIT_COMMIT_COMMAND="$GIT_COMMIT_COMMAND -m \"${PR_TITLE_PREFIX}\"" +eval "$GIT_COMMIT_COMMAND" REPO_URL="https://" REPO_URL+="${AUTHOR}:${TOKEN}@github.com/" REPO_URL+="${REPOSITORY}.git" GITHUB_HEAD="HEAD:refs/heads/${BRANCH_NAME_PREFIX}-${HEAD_REF}" -git push -f "${REPO_URL}" "${GITHUB_HEAD}" +GIT_PUSH_COMMAND="git push" + +if [ "$NO_VERIFY" = "true" ]; then + GIT_PUSH_COMMAND="$GIT_PUSH_COMMAND --no-verify" +fi + +GIT_PUSH_COMMAND="$GIT_PUSH_COMMAND -f \"${REPO_URL}\" \"${GITHUB_HEAD}\"" +eval "$GIT_PUSH_COMMAND"