-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pre-commit): migrate from apm-pipeline-library (#119)
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# <!--name-->pre-commit<!--/name--> | ||
|
||
[![usages](https://img.shields.io/badge/usages-white?logo=githubactions&logoColor=blue)](https://github.com/search?q=elastic%2Foblt-actions%2Fpre-commit+%28path%3A.github%2Fworkflows+OR+path%3A**%2Faction.yml+OR+path%3A**%2Faction.yaml%29&type=code) | ||
|
||
<!--description--> | ||
Run pre-commit independently you are running on a PR or a branch. | ||
<!--/description--> | ||
|
||
## Inputs | ||
|
||
<!--inputs--> | ||
| Name | Description | Required | Default | | ||
|------------------|-------------------------------------------------------------------------------|----------|---------| | ||
| `clean-checkout` | Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching | `false` | `true` | | ||
<!--/inputs--> | ||
|
||
## Usage | ||
|
||
<!--usage action="elastic/oblt-actions/**" version="env:VERSION"--> | ||
```yaml | ||
on: | ||
pull_request: ~ | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: elastic/oblt-actions/pre-commit@v1 | ||
``` | ||
<!--/usage--> |
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,29 @@ | ||
--- | ||
name: 'pre-commit' | ||
description: | | ||
Run pre-commit independently you are running on a PR or a branch. | ||
inputs: | ||
clean-checkout: | ||
default: "true" | ||
description: "Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
clean: ${{ inputs.clean-checkout }} | ||
# Fetch all the history so the pre-commit/action can compare changes between the target and the git commit | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Run pre-commit on PRs | ||
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 | ||
if: ${{ github.event.pull_request }} | ||
with: | ||
extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Run pre-commit on branches | ||
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 | ||
if: ${{ ! github.event.pull_request }} |