Skip to content

Commit c54592f

Browse files
committed
ci: skip sqlfluff annotate on fork PRs
same fix as #2148 — skip annotate when head repo is a fork
1 parent b781ec9 commit c54592f

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎.github/workflows/lint_sqlfluff.yml‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
name: SQLFluff
22

3+
# Lints changed mimic-iv/concepts/*.sql on pull requests and posts GitHub
4+
# annotations. Fork PRs skip Annotate — GITHUB_TOKEN cannot create check runs
5+
# from forks (Resource not accessible by integration / 403).
36
on:
47
- pull_request
58

69
jobs:
710
lint-mimic-iv:
811
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
checks: write
915
steps:
1016
- name: checkout
1117
uses: actions/checkout@v7
@@ -35,8 +41,14 @@ jobs:
3541
shell: bash
3642
run: sqlfluff lint --format github-annotation --annotation-level failure --nofail ${{ steps.get_files_to_lint.outputs.lintees }} > annotations.json
3743
- name: Annotate
44+
# Same-repo PRs only: fork tokens get 403 creating check runs, and
45+
# ignore-unauthorized-error does not treat that as unauthorized.
46+
if: >
47+
steps.get_files_to_lint.outputs.lintees != '' &&
48+
github.event.pull_request.head.repo.full_name == github.repository
3849
uses: yuzutech/annotations-action@v0.6.0
3950
with:
4051
repo-token: "${{ secrets.GITHUB_TOKEN }}"
4152
title: "SQLFluff Lint"
42-
input: "./annotations.json"
53+
input: "./annotations.json"
54+
ignore-unauthorized-error: true

0 commit comments

Comments
 (0)