-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Kpler/story/add-generic-github-action
feat: add generic gh action
- Loading branch information
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: 'Pre-commit' | ||
description: 'Run pre-commit hooks' | ||
inputs: | ||
skipped-hooks: | ||
description: 'Skip some hooks, eg "no-commit-to-branch,foo"' | ||
required: true | ||
default: '' | ||
main-branch: | ||
description: 'master or main' | ||
required: true | ||
default: 'main' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-python@v2 | ||
- name: Skip some hooks | ||
run: echo "SKIP=${{ inputs.skipped-hooks }}" >> $GITHUB_ENV | ||
if: ${{ inputs.skipped-hooks }} != '' | ||
shell: bash | ||
- name: Install pre-commit | ||
run: pip install pre-commit | ||
shell: bash | ||
- name: Cache pre-commit hooks | ||
uses: actions/cache@v2 | ||
with: | ||
path: '~/.cache/pre-commit' | ||
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | ||
- name: Run pre-commit | ||
run: | | ||
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage commit | ||
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage push | ||
# https://github.com/jorisroovers/gitlint/issues/148 | ||
git config --add user.email '' | ||
git config --add user.name '' | ||
git fetch origin ${{ inputs.main-branch }} 2> /dev/null | ||
for commit in $(git rev-list origin/${{ inputs.main-branch }}..HEAD) | ||
do | ||
git show -s --pretty=format:%B $commit > tmp | ||
pre-commit run --color=always --hook-stage commit-msg --commit-msg-filename tmp | ||
done | ||
shell: bash | ||
|