Skip to content

Commit 5a056a4

Browse files
committed
docs: Document how to use GH workflows in forks.
And disable useless workflows runs in CI
1 parent c613da7 commit 5a056a4

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

.github/CONTRIBUTING.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,13 @@
1313
* [Add code](#add-code)
1414
* [Finish with the documentation](#finish-with-the-documentation)
1515
* [Contributing to Python code](#contributing-to-python-code)
16+
* [Run tests in your fork](#run-tests-in-your-fork)
1617

1718
## Run and debug hooks locally
1819

1920
```bash
2021
pre-commit try-repo {-a} /path/to/local/pre-commit-terraform/repo {hook_name}
21-
```
22-
23-
I.e.
24-
25-
```bash
26-
pre-commit try-repo /mnt/c/Users/tf/pre-commit-terraform terraform_fmt # Run only `terraform_fmt` check
27-
pre-commit try-repo -a ~/pre-commit-terraform # run all existing checks from repo
28-
```
29-
30-
Running `pre-commit` with `try-repo` ignores all arguments specified in `.pre-commit-config.yaml`.
31-
32-
If you need to test hook with arguments, follow [pre-commit doc](https://pre-commit.com/#arguments-pattern-in-hooks) to test hooks.
33-
34-
For example, to test that the [`terraform_fmt`](../README.md#terraform_fmt) hook works fine with arguments:
35-
22+
```g run on this fork
3623
```bash
3724
/tmp/pre-commit-terraform/terraform_fmt.sh --args=-diff --args=-write=false test-dir/main.tf test-dir/vars.tf
3825
```
@@ -182,3 +169,11 @@ You can use [this PR](https://github.com/antonbabenko/pre-commit-terraform/pull/
182169
```bash
183170
tox list
184171
```
172+
173+
## Run tests in your fork
174+
175+
Go to you fork `Actions` tab and click on big green button
176+
177+
![Enable workflows](/assets/contributing/enable_actions_in_fork.png)
178+
179+
Now you can see are the tests pass before submitting PR.

.github/workflows/ci-cd.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ jobs:
8484
name: ⚙️ Pre-set global build settings
8585

8686
runs-on: ubuntu-latest
87+
# Prevent run 'push' events for the branches in upstream repository as it
88+
# already covered by 'pull_request' event
89+
if: (github.event_name == 'push' && github.repository == 'pre-commit/pre-commit-terraform' &&
90+
github.branch == 'master') ||
91+
(github.event_name == 'push' && github.repository != 'pre-commit/pre-commit-terraform') ||
92+
github.event_name != 'push'
8793

8894
timeout-minutes: 1
8995

196 KB
Loading

0 commit comments

Comments
 (0)