Skip to content

Commit 8a65534

Browse files
git commit, push時に--no-verifyを付与するオプション追加 (#1430)
* 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>
1 parent e5bdc4f commit 8a65534

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
| pr-description-prefix | 本文の接頭語。 | | |
4747
| exit-failure | 実行完了時にCIを失敗させるかどうか。 | | true |
4848
| working-directory | 実行対象のディレクトリ | | |
49+
| no-verify | git commit, push時のフックを無効化する | | false |
4950
5051
## 対応しているトリガー
5152
* pull_request

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ inputs:
2525
description: '実行対象のディレクトリ'
2626
required: false
2727
default: ""
28+
no-verify:
29+
description: 'git commit, push時のフックを無効化する'
30+
required: false
31+
default: "false"
2832
runs:
2933
using: "composite"
3034
steps:
@@ -46,6 +50,7 @@ runs:
4650
TOKEN: ${{inputs.github-token}}
4751
REPOSITORY: ${{github.repository}}
4852
BRANCH_NAME_PREFIX: ${{inputs.branch-name-prefix}}
53+
NO_VERIFY: ${{inputs.no-verify}}
4954
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')
5055
working-directory: ${{inputs.working-directory}}
5156
run: ${{ github.action_path }}/scripts/action/push.sh

scripts/action/push.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,23 @@
33
git config user.name "github-actions[bot]"
44
EMAIL="41898282+github-actions[bot]@users.noreply.github.com"
55
git config user.email "${EMAIL}"
6-
git commit -m "${PR_TITLE_PREFIX}"
6+
GIT_COMMIT_COMMAND="git commit"
7+
8+
if [ "$NO_VERIFY" = "true" ]; then
9+
GIT_COMMIT_COMMAND="$GIT_COMMIT_COMMAND --no-verify"
10+
fi
11+
12+
GIT_COMMIT_COMMAND="$GIT_COMMIT_COMMAND -m \"${PR_TITLE_PREFIX}\""
13+
eval "$GIT_COMMIT_COMMAND"
714
REPO_URL="https://"
815
REPO_URL+="${AUTHOR}:${TOKEN}@github.com/"
916
REPO_URL+="${REPOSITORY}.git"
1017
GITHUB_HEAD="HEAD:refs/heads/${BRANCH_NAME_PREFIX}-${HEAD_REF}"
11-
git push -f "${REPO_URL}" "${GITHUB_HEAD}"
18+
GIT_PUSH_COMMAND="git push"
19+
20+
if [ "$NO_VERIFY" = "true" ]; then
21+
GIT_PUSH_COMMAND="$GIT_PUSH_COMMAND --no-verify"
22+
fi
23+
24+
GIT_PUSH_COMMAND="$GIT_PUSH_COMMAND -f \"${REPO_URL}\" \"${GITHUB_HEAD}\""
25+
eval "$GIT_PUSH_COMMAND"

0 commit comments

Comments
 (0)