Skip to content

Commit 043c690

Browse files
author
Github Actions
committed
Deployed to github pages
0 parents  commit 043c690

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
[![Build Status](https://github.com/pre-commit/action/workflows/deploy/badge.svg)](https://github.com/pre-commit/action/actions)
2+
3+
pre-commit/action
4+
=================
5+
6+
a GitHub action to run [pre-commit](https://pre-commit.com)
7+
8+
### using this action
9+
10+
To use this action, make a file `.github/workflows/pre-commit.yml`. Here's a
11+
template to get started:
12+
13+
```yaml
14+
on:
15+
pull_request:
16+
push:
17+
branches: [master]
18+
19+
jobs:
20+
pre-commit:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v1
24+
- uses: actions/setup-python@v1
25+
- name: set PY
26+
run: echo "::set-env name=PY::$(python --version --version | sha256sum | cut -d' ' -f1)"
27+
- uses: actions/cache@v1
28+
with:
29+
path: ~/.cache/pre-commit
30+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
31+
- uses: pre-commit/[email protected]
32+
```
33+
34+
This does a few things:
35+
36+
- clones the code
37+
- installs python
38+
- sets up the `pre-commit` cache
39+
40+
Hopefully in the future when `actions` matures the yaml can be simplified.
41+
42+
### using this action in private repositories
43+
44+
this action also provides an additional behaviour when used in private
45+
repositories. when configured with a github token, the action will push back
46+
fixes to the pull request branch.
47+
48+
here's an example configuration for that (use the template above except for the
49+
`pre-commit` action):
50+
51+
```yaml
52+
- uses: pre-commit/[email protected]
53+
with:
54+
token: ${{ secrets.GITHUB_TOKEN }}
55+
```
56+
57+
note that `secrets.GITHUB_TOKEN` is automatically provisioned and will not
58+
require any special configuration.
59+
60+
while you could _technically_ configure this for a public repository (using a
61+
personal access token), I can't think of a way to do this safely without
62+
exposing a privileged token to pull requests -- if you have any ideas, please
63+
leave an issue!

action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: pre-commit
2+
description: run pre-commit and optionally commit back to the pull request
3+
inputs:
4+
token:
5+
description: github token to clone / push with
6+
required: false
7+
runs:
8+
using: 'node12'
9+
main: 'dist/index.js'

dist/index.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)