Skip to content

Commit

Permalink
git commit, push時に--no-verifyを付与するオプション追加 (#1430)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
massongit and github-actions[bot] authored Dec 19, 2023
1 parent e5bdc4f commit 8a65534
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
| pr-description-prefix | 本文の接頭語。 | | |
| exit-failure | 実行完了時にCIを失敗させるかどうか。 | | true |
| working-directory | 実行対象のディレクトリ | | |
| no-verify | git commit, push時のフックを無効化する | | false |
## 対応しているトリガー
* pull_request
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ inputs:
description: '実行対象のディレクトリ'
required: false
default: ""
no-verify:
description: 'git commit, push時のフックを無効化する'
required: false
default: "false"
runs:
using: "composite"
steps:
Expand All @@ -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
Expand Down
18 changes: 16 additions & 2 deletions scripts/action/push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 8a65534

Please sign in to comment.