GitHub Action: SARIF and PR comments

    The PTKD GitHub Action runs ptkd check inside the GitHub runner on every pull request and push. Your code stays in the runner.

    Set it up

    # .github/workflows/ptkd.yml
    name: PTKD
    on:
      pull_request:
      push:
        branches: [main]
    permissions:
      contents: read
      pull-requests: write     # comments
      security-events: write   # SARIF upload
    jobs:
      ptkd:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          - uses: VP0COM/PTKDCOM/tools/github-action@main
            with:
              path: apps/mobile   # your app folder

    What it does

    • Checks the head and the base. On a pull request it also checks the base commit, so it knows which findings the pull request adds.
    • Comments on changed lines. A new finding that sits on a line the pull request adds gets a review comment there, with the fix. Findings already on the base branch are not repeated.
    • Keeps one summary comment. Every new finding, the verdict and both scores, updated in place on each push.
    • Uploads SARIF to GitHub code scanning, so findings show in the Security tab.
    • Gates the job. On a pull request only new blocking findings fail it, so old findings do not block unrelated work. On a push, the verdict of the commit decides. A check that could not run fails unless you allow it.

    Line comments need the finding to carry a file and line. Findings that point at a package, a config value or the app as a whole go into the summary comment instead.

    Inputs and outputs

    InputDefaultWhat it does
    path.The app folder, or a built IPA, APK or AAB.
    fail-onhighcritical, high, medium, low or none.
    gatetrueFail the job when the gate fails.
    allow-uncheckedfalsePass when nothing could be checked.
    comment-prtrueLine comments and the summary comment.
    upload-sariftrueUpload to code scanning.

    Outputs: verdict, findings-count, new-findings-count, gate, sarif-file.

    Pull requests from forks

    GitHub gives pull requests from forks a read-only token. The action then skips the comments with a warning; the check, the SARIF file and the gate still work.