Skip to content

Commit c91b8fb

Browse files
natterstefanamannn
andauthored
docs: Add permissions (#215 by @natterstefan)
Co-authored-by: Jan Amann <[email protected]>
1 parent ff373f4 commit c91b8fb

9 files changed

+99
-36
lines changed

.github/workflows/lint-pr-title-preview-ignoreLabels.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ on:
88
- labeled
99
- unlabeled
1010

11+
permissions:
12+
pull-requests: read
13+
1114
jobs:
1215
main:
1316
runs-on: ubuntu-latest
1417
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions/setup-node@v2
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
1720
with:
1821
node-version: 16
1922
- run: yarn install

.github/workflows/lint-pr-title-preview-outputErrorMessage.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ on:
66
- edited
77
- synchronize
88

9+
permissions:
10+
pull-requests: read
11+
912
jobs:
1013
main:
1114
runs-on: ubuntu-latest
1215
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
1518
with:
1619
node-version: 16
1720
- run: yarn install

.github/workflows/lint-pr-title-preview-validateSingleCommit.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ on:
66
- edited
77
- synchronize
88

9+
permissions:
10+
pull-requests: read
11+
912
jobs:
1013
main:
1114
runs-on: ubuntu-latest
1215
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
1518
with:
1619
node-version: 16
1720
- run: yarn install

.github/workflows/lint-pr-title-preview.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ on:
66
- edited
77
- synchronize
88

9+
permissions:
10+
pull-requests: read
11+
912
jobs:
1013
main:
1114
runs-on: ubuntu-latest
1215
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
1518
with:
1619
node-version: 16
1720
- run: yarn install

.github/workflows/lint-pr-title.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ on:
66
- edited
77
- synchronize
88

9+
permissions:
10+
pull-requests: read
11+
912
jobs:
1013
main:
1114
runs-on: ubuntu-latest
1215
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
1518
with:
1619
node-version: 16
1720
- uses: ./

.github/workflows/release.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ on:
44
branches:
55
- main
66

7+
permissions:
8+
contents: read
9+
deployments: write
10+
issues: write
11+
pull-requests: write
12+
713
jobs:
814
main:
915
runs-on: ubuntu-latest
1016
steps:
11-
- uses: actions/checkout@v1
12-
- uses: actions/setup-node@v2
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
1319
with:
1420
node-version: 16
1521
- run: yarn install

.github/workflows/test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ on:
66
- reopened
77
- synchronize
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
main:
1114
runs-on: ubuntu-latest
1215
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
1518
with:
1619
node-version: 16
1720
- run: yarn install
@@ -20,7 +23,7 @@ jobs:
2023
dist:
2124
runs-on: ubuntu-latest
2225
steps:
23-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2427
with:
2528
fetch-depth: 0
2629
- name: Check if `dist/` has been modified.

.github/workflows/versioning.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
release:
55
types: [published, edited]
66

7+
permissions:
8+
deployments: write
9+
710
jobs:
811
actions-tagger:
912
runs-on: ubuntu-latest

README.md

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# action-semantic-pull-request
22

3-
This is a GitHub Action that ensures your PR title matches the [Conventional Commits spec](https://www.conventionalcommits.org/). The typical use case is to use this in combination with a tool like [semantic-release](https://github.com/semantic-release/semantic-release) to automate releases.
3+
This is a GitHub Action that ensures that your pull request titles match the [Conventional Commits spec](https://www.conventionalcommits.org/). Typically, this is used in combination with a tool like [semantic-release](https://github.com/semantic-release/semantic-release) to automate releases.
44

55
Used by: [Apache](https://github.com/apache/pulsar) · [Vercel](https://github.com/vercel/ncc) · [Microsoft](https://github.com/microsoft/SynapseML) · [Firebase](https://github.com/firebase/flutterfire) · [AWS](https://github.com/aws-ia/terraform-aws-eks-blueprints) · [Electron](https://github.com/electron/forge) – and [many more](https://github.com/amannn/action-semantic-pull-request/network/dependents).
66

77
## Examples
88

9-
**Valid PR titles:**
9+
**Valid pull request titles:**
1010
- fix: Correct typo
1111
- feat: Add support for Node.js 18
1212
- refactor!: Drop support for Node.js 12
1313
- feat(ui): Add `Button` component
1414

15-
> Note that since PR titles only have a single line, you have to use `!` to indicate breaking changes.
15+
> Note that since pull request titles only have a single line, you have to use `!` to indicate breaking changes.
1616
1717
See [Conventional Commits](https://www.conventionalcommits.org/) for more examples.
1818

@@ -30,6 +30,9 @@ on:
3030
- edited
3131
- synchronize
3232

33+
permissions:
34+
pull-requests: read
35+
3336
jobs:
3437
main:
3538
name: Validate PR title
@@ -40,6 +43,8 @@ jobs:
4043
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4144
```
4245
46+
See the [event triggers documentation](#event-triggers) below to learn more about what `pull_request_target` means.
47+
4348
## Configuration
4449

4550
The action works without configuration, however you can provide options for customization.
@@ -102,15 +107,55 @@ feat(ui): Add `Button` component
102107
# See: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#headerpattern
103108
headerPattern: '^(\w*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$'
104109
headerPatternCorrespondence: type, scope, subject
105-
# For work-in-progress PRs you can typically use draft pull requests
106-
# from GitHub. However, private repositories on the free plan don't have
107-
# this option and therefore this action allows you to opt-in to using the
108-
# special "[WIP]" prefix to indicate this state. This will avoid the
109-
# validation of the PR title and the pull request checks remain pending.
110-
# Note that a second check will be reported if this is enabled.
110+
```
111+
112+
### Work-in-progress pull requests
113+
114+
For work-in-progress PRs you can typically use [draft pull requests from GitHub](https://github.blog/2019-02-14-introducing-draft-pull-requests/). However, private repositories on the free plan don't have this option and therefore this action allows you to opt-in to using the special "[WIP]" prefix to indicate this state.
115+
116+
**Example:**
117+
118+
```
119+
[WIP] feat: Add support for Node.js 18
120+
```
121+
122+
This will prevent the PR title from being validated, and pull request checks will remain pending.
123+
124+
**Attention**: If you want to use the this feature, you need to grant the `pull-requests: write` permission to the GitHub Action. This is because the action will update the status of the PR to remain in a pending state while `[WIP]` is present in the PR title.
125+
126+
```yml
127+
name: "Lint PR"
128+
129+
permissions:
130+
pull-requests: write
131+
132+
jobs:
133+
main:
134+
name: Validate PR title
135+
runs-on: ubuntu-latest
136+
steps:
137+
- uses: amannn/action-semantic-pull-request@v5
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
with:
111141
wip: true
112142
```
113143

144+
### Legacy configuration for validating single commits
145+
146+
When using "Squash and merge" on a PR with only one commit, GitHub will suggest using that commit message instead of the PR title for the merge commit. As it's easy to commit this by mistake this action supports two configuration options to provide additional validation for this case.
147+
148+
```yml
149+
# If the PR only contains a single commit, the action will validate that
150+
# it matches the configured pattern.
151+
validateSingleCommit: true
152+
# Related to `validateSingleCommit` you can opt-in to validate that the PR
153+
# title matches a single commit to avoid confusion.
154+
validateSingleCommitMatchesPrTitle: true
155+
```
156+
157+
However, [GitHub has introduced an option to streamline this behaviour](https://github.blog/changelog/2022-05-11-default-to-pr-titles-for-squash-merge-commit-messages/), so using that instead should be preferred.
158+
114159
## Event triggers
115160
116161
There are two events that can be used as triggers for this action, each with different characteristics:
@@ -137,6 +182,9 @@ on:
137182
- edited
138183
- synchronize
139184
185+
permissions:
186+
pull-requests: read
187+
140188
jobs:
141189
main:
142190
name: Validate PR title
@@ -174,15 +222,3 @@ jobs:
174222
175223
</details>
176224
177-
## Legacy configuration
178-
179-
When using "Squash and merge" on a PR with only one commit, GitHub will suggest using that commit message instead of the PR title for the merge commit and it's easy to commit this by mistake. To help out in this situation this action supports two configuration options. However, [GitHub has introduced an option to streamline this behaviour](https://github.blog/changelog/2022-05-11-default-to-pr-titles-for-squash-merge-commit-messages/), so using that instead should be preferred.
180-
181-
```yml
182-
# If the PR only contains a single commit, the action will validate that
183-
# it matches the configured pattern.
184-
validateSingleCommit: true
185-
# Related to `validateSingleCommit` you can opt-in to validate that the PR
186-
# title matches a single commit to avoid confusion.
187-
validateSingleCommitMatchesPrTitle: true
188-
```

0 commit comments

Comments
 (0)