Skip to content

Commit 861265b

Browse files
authored
Run pre-commit in forks (#556)
1 parent 74c4bb0 commit 861265b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,26 @@ jobs:
2121
!contains(github.event.pull_request.labels.*.name, 'ci/skip') &&
2222
!contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/')
2323
steps:
24+
# Run only in this repository
2425
- name: Get GitHub App token
2526
id: get_token
27+
if: github.event.pull_request.head.repo.full_name == github.repository
2628
uses: tibdex/github-app-token@v1
2729
with:
2830
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
2931
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
3032
- uses: actions/checkout@v2
33+
if: github.event.pull_request.head.repo.full_name == github.repository
3134
with:
3235
fetch-depth: 0
3336
ref: ${{ github.event.pull_request.head.sha }}
3437
token: ${{ steps.get_token.outputs.token }}
38+
# Fetch a fork of the repo
39+
- uses: actions/checkout@v2
40+
if: github.event.pull_request.head.repo.full_name != github.repository
41+
with:
42+
fetch-depth: 0
43+
ref: ${{ github.event.pull_request.head.sha }}
3544
- name: Install pre-commit
3645
run: python -m pip install pre-commit
3746
- name: set PY
@@ -46,7 +55,7 @@ jobs:
4655
run: |
4756
pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
4857
- name: Commit changes
49-
if: ${{ failure() }}
58+
if: github.event.pull_request.head.repo.full_name == github.repository && failure()
5059
run: |-
5160
git add -A
5261
git config user.name "${GIT_AUTHOR_NAME}"

0 commit comments

Comments
 (0)