Skip to content

Commit f5c2d25

Browse files
committed
remove pushing behaviour
1 parent c674242 commit f5c2d25

File tree

11 files changed

+49
-4331
lines changed

11 files changed

+49
-4331
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: main
2+
on:
3+
pull_request:
4+
push:
5+
branches: [main, test-me-*]
6+
7+
jobs:
8+
main:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-python@v3
13+
- name: self test action
14+
uses: ./

.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@ repos:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
77
- id: check-yaml
8-
- repo: https://github.com/pre-commit/mirrors-eslint
9-
rev: v8.16.0
10-
hooks:
11-
- id: eslint
12-
args: [--fix]

Makefile

Lines changed: 0 additions & 24 deletions
This file was deleted.

README.md

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Please switch to using [pre-commit.ci] which is faster and has more features.
88
___
99

1010
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pre-commit/action/main.svg)](https://results.pre-commit.ci/latest/github/pre-commit/action/main)
11-
[![Build Status](https://github.com/pre-commit/action/workflows/deploy/badge.svg)](https://github.com/pre-commit/action/actions)
11+
[![Build Status](https://github.com/pre-commit/action/workflows/main/badge.svg)](https://github.com/pre-commit/action/actions)
1212

1313
pre-commit/action
1414
=================
@@ -32,8 +32,8 @@ jobs:
3232
pre-commit:
3333
runs-on: ubuntu-latest
3434
steps:
35-
- uses: actions/checkout@v2
36-
- uses: actions/setup-python@v2
35+
- uses: actions/checkout@v3
36+
- uses: actions/setup-python@v3
3737
- uses: pre-commit/[email protected]
3838
```
3939
@@ -59,33 +59,26 @@ the files (use the template above except for the `pre-commit` action):
5959

6060
### using this action in private repositories
6161

62-
this action also provides an additional behaviour when used in private
63-
repositories. when configured with a github token, the action will push back
64-
fixes to the pull request branch.
62+
prior to v3.0.0, this action had custom behaviour which pushed changes back to
63+
the pull request when supplied with a `token`.
6564

66-
using the template above, you'll make two replacements for individual actions:
65+
this behaviour was removed:
66+
- it required a PAT (didn't work with short-lived `GITHUB_TOKEN`)
67+
- properly hiding this `input` from the installation and execution of hooks
68+
is intractable in github actions (it is readily available as `$INPUT_TOKEN`)
69+
- this meant potentially unvetted code could access the token via the
70+
environment
6771

68-
first is the checkout step, which needs to use unlimited fetch depth for
69-
pushing
72+
you can _likely_ achieve the same thing with an external action such as
73+
[git-auto-commit-action] though you may want to take precautions to clear `git`
74+
hooks or other ways that arbitrary code execution can occur when running
75+
`git commit` / `git push` (for example [core.fsmonitor]).
7076

71-
```yaml
72-
- uses: actions/checkout@v2
73-
with:
74-
fetch-depth: 0
75-
```
77+
while unrelated to this action, [pre-commit.ci] avoids these problems by
78+
installing and executing isolated from the short-lived repository-scoped
79+
[installation access token].
7680

77-
next is passing the token to the pre-commit action
78-
79-
```yaml
80-
- uses: pre-commit/[email protected]
81-
with:
82-
token: ${{ secrets.GITHUB_TOKEN }}
83-
```
84-
85-
note that `secrets.GITHUB_TOKEN` is automatically provisioned and will not
86-
require any special configuration.
87-
88-
while you could _technically_ configure this for a public repository (using a
89-
personal access token), I can't think of a way to do this safely without
90-
exposing a privileged token to pull requests -- if you have any ideas, please
91-
leave an issue!
81+
[git-auto-commit-action]: https://github.com/stefanzweifel/git-auto-commit-action
82+
[core.fsmonitor]: https://github.blog/2022-04-12-git-security-vulnerability-announced/
83+
[pre-commit.ci]: https://pre-commit.ci
84+
[installation access token]: https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app

action.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
name: pre-commit
2-
description: run pre-commit and optionally commit back to the pull request
2+
description: run pre-commit
33
inputs:
44
extra_args:
55
description: options to pass to pre-commit run
66
required: false
77
default: '--all-files'
8-
token:
9-
description: github token to clone / push with
10-
required: false
118
runs:
12-
using: 'node12'
13-
main: 'dist/index.js'
9+
using: composite
10+
steps:
11+
- run: python -m pip install pre-commit
12+
shell: bash
13+
- run: python -m pip freeze --local
14+
shell: bash
15+
- uses: actions/cache@v3
16+
with:
17+
path: ~/.cache/pre-commit
18+
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
19+
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
20+
shell: bash

index.js

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)