You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 63406a5
Browse filesBrowse the repository at this point in the historyBrowse files
Show a recommended setup with and without code scanning
The README had one recommended setup and, further down, a bare job
with the permission for the code scanning report. Now the recommended
setup comes in two complete workflows side by side: one that announces
a newer open-java-format release in the job log alone, and one that
also raises the code scanning alert, with the permissions that takes.
The code scanning section points at the second instead of repeating
it.
The action compares the `version` it runs with the latest [open-java-format release](https://github.com/openjavaformat/open-java-format/releases) and warns in the job log when a newer one is out. A log warning is easy to miss, so the check can also be reported to code scanning: the action then uploads a SARIF file with one alert while the version is behind, and with none once it is current, which closes the alert. The alert shows up under **Security → Code scanning** and in the **Code scanning results** check on pull requests, and points at the line of the workflow that names the version.
97
+
### With the version check in code scanning too
94
98
95
-
This is off by default, because the upload needs the `security-events: write` permission, which the default token does not have. To turn it on, set `code-scanning: true` and give the job the permission:
99
+
The same, plus a [code scanning alert](#code-scanning) that stays open until the version is updated. It takes `code-scanning: true` and the `security-events: write` permission; the `permissions` block replaces the job's default permissions, so it names everything else the job needs as well.
96
100
97
101
```yaml
102
+
on:
103
+
pull_request:
104
+
push:
105
+
branches: [main]
106
+
98
107
jobs:
99
108
format:
100
109
runs-on: ubuntu-latest
101
110
permissions:
102
-
contents: read
111
+
contents: read # the checkout
103
112
pull-requests: read # mode: changed reads the files of the pull request
The `permissions` block replaces the default permissions of the job, so it has to name everything else the job needs, such as `contents: read` for the checkout. If the permission is missing anyway, the upload is skipped with a line in the log, the check passes as before, and the log warning stays. Code scanning is free on public repositories; a private repository needs [GitHub Code Security](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-security-and-analysis-settings-for-your-repository) enabled. Pull requests from forks run with a read-only token and get the log warning only.
124
+
## Code scanning
125
+
126
+
The action compares the `version` it runs with the latest [open-java-format release](https://github.com/openjavaformat/open-java-format/releases) and warns in the job log when a newer one is out. A log warning is easy to miss, so the check can also be reported to code scanning: the action then uploads a SARIF file with one alert while the version is behind, and with none once it is current, which closes the alert. The alert shows up under **Security → Code scanning** and in the **Code scanning results** check on pull requests, and points at the line of the workflow that names the version.
127
+
128
+
This is off by default, because the upload needs the `security-events: write` permission, which the default token does not have. To turn it on, set `code-scanning: true` and give the job the permission, as in the [second recommended setup](#with-the-version-check-in-code-scanning-too). If the permission is missing anyway, the upload is skipped with a line in the log, the check passes as before, and the log warning stays. Code scanning is free on public repositories; a private repository needs [GitHub Code Security](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-security-and-analysis-settings-for-your-repository) enabled. Pull requests from forks run with a read-only token and get the log warning only.
115
129
116
130
One report per job is enough. When the job runs on a matrix, turn it on for one leg only:
0 commit comments