Skip to content

Commit 3f68a95

Browse files
docs: Document how to use GH workflows in forks (#821)
--------- Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
1 parent 0ab40da commit 3f68a95

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

.github/CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
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

@@ -182,3 +183,11 @@ You can use [this PR](https://github.com/antonbabenko/pre-commit-terraform/pull/
182183
```bash
183184
tox list
184185
```
186+
187+
## Run tests in your fork
188+
189+
Go to your fork's `Actions` tab and click the big green button.
190+
191+
![Enable workflows](/assets/contributing/enable_actions_in_fork.png)
192+
193+
Now you can verify that the tests pass before submitting your PR.

.github/workflows/ci-cd.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ env:
5252
PYTHONIOENCODING
5353
PYTHONLEGACYWINDOWSSTDIO
5454
PYTHONUTF8
55-
UPSTREAM_REPOSITORY_ID: >-
56-
69382485
55+
UPSTREAM_REPOSITORY_ID: 69382485 # Repo ID of antonbabenko/pre-commit-terraform
5756

5857
run-name: >-
5958
${{
@@ -255,6 +254,13 @@ jobs:
255254
name: 📦 ${{ needs.pre-setup.outputs.git-tag }}
256255
needs:
257256
- pre-setup
257+
# Prevent run 'push' events for the branches in upstream repository as it
258+
# already covered by 'pull_request' event
259+
if: >-
260+
github.repository_id != needs.pre-setup.outputs.upstream-repository-id
261+
|| github.event_name != 'push'
262+
|| github.ref_name == github.event.repository.default_branch
263+
258264
259265
runs-on: ubuntu-latest
260266

@@ -502,6 +508,12 @@ jobs:
502508
codecov-token: ${{ secrets.CODECOV_TOKEN }}
503509

504510
check: # This job does nothing and is only used for the branch protection
511+
512+
# Separate 'pull_request' check from other checks to avoid confusion in
513+
# GitHub branch protection about which check is required when multiple
514+
# events trigger this workflow.
515+
name: >-
516+
${{ github.event_name == 'push' && 'check&ZeroWidthSpace;' || 'check' }}
505517
if: always()
506518

507519
needs:
@@ -517,3 +529,15 @@ jobs:
517529
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
518530
with:
519531
jobs: ${{ toJSON(needs) }}
532+
# Needed to not fail on skipped 'push' events for the branches in
533+
# upstream repository as they already covered by 'pull_request' event
534+
allowed-skips: >-
535+
${{
536+
(
537+
github.repository_id != needs.pre-setup.outputs.upstream-repository-id
538+
|| github.event_name != 'push'
539+
|| github.ref_name == github.event.repository.default_branch
540+
)
541+
&& 'lint, tests'
542+
|| ''
543+
}}
196 KB
Loading

0 commit comments

Comments
 (0)