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
Copy file name to clipboardExpand all lines: README.md
+18-10Lines changed: 18 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,19 +93,27 @@ Subsequent actions will have access to the following outputs:
93
93
**Note:** By default, these outputs will only be populated if the target Pull Request was opened by Dependabot and contains
94
94
**only** Dependabot-created commits. To override, see `skip-commit-verification` / `skip-verification`.
95
95
96
-
For workflows initiated by Dependabot (`github.actor == 'dependabot[bot]'`) using the `pull_request_target` event, if the base ref of the pull request was created by Dependabot (`github.event.pull_request.user.login == 'dependabot[bot]'`), the `GITHUB_TOKEN` will be read-only and secrets are not available.
97
-
98
96
This metadata can be used along with Action's [expression syntax](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#functions) and the [GitHub CLI](https://github.com/cli/cli) to create
99
97
useful automation for your Dependabot PRs.
100
98
99
+
> [!NOTE]
100
+
> Workflows triggered by Dependabot on the `pull_request` event [run with a read-only `GITHUB_TOKEN`](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#permissions-for-workflow-runs-triggered-by-dependabot) and cannot access user-defined repository or organization secrets. The GitHub-provided token is still available, but only with read-only permissions (prefer `github.token` when referring to that built-in token in examples). If your workflow needs write permissions or access to user-defined secrets, use the [`pull_request_target`](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request_target) event or a separate workflow triggered by [`workflow_run`](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_run). The examples below use `pull_request_target` for this reason.
101
+
101
102
### Auto-approving
102
103
103
104
Since the `dependabot/fetch-metadata` Action will set a failure code if it cannot find any metadata, you can
104
105
have a permissive auto-approval on all Dependabot PRs like so:
105
106
107
+
> [!NOTE]
108
+
> The `GITHUB_TOKEN` approval will come from the `github-actions[bot]` user.
109
+
> If your branch protection rules use ["Require approval of the most recent reviewable push"](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches#require-pull-request-reviews-before-merging)
110
+
> or restrict which users/teams can provide approving reviews, this approval may not satisfy your merge requirements.
111
+
> In those cases, consider using a [PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
112
+
> or [GitHub App token](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app) instead, but store that credential as a secret, grant it the least privilege needed, and do not expose it to untrusted or PR-controlled code paths. This is especially important for workflows triggered by `pull_request_target`: do not make such secrets available to steps that run code from the pull request.
113
+
106
114
```yaml
107
115
name: Dependabot auto-approve
108
-
on: pull_request
116
+
on: pull_request_target
109
117
permissions:
110
118
pull-requests: write
111
119
jobs:
@@ -133,13 +141,13 @@ jobs:
133
141
### Enabling auto-merge
134
142
135
143
If you are using [the auto-merge feature](https://docs.github.com/en/github/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request) on your repository,
136
-
you can set up an action that will enable Dependabot PRs to merge once CI and other [branch protection rules](https://docs.github.com/en/github/administering-a-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule) are met. (Note that you must use a [personal access token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) when executing the merge instruction.)
144
+
you can set up an action that will enable Dependabot PRs to merge once CI and other [branch protection rules](https://docs.github.com/en/github/administering-a-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule) are met. Enabling auto-merge requires [write permissions](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request#enabling-auto-merge) on the repository. When using `pull_request_target`, the `GITHUB_TOKEN` [has read/write access](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#permissions) and satisfies this requirement when configured with `contents: write` and `pull-requests: write`.
137
145
138
146
For example, if you want to automatically merge all patch updates to Rails:
139
147
140
148
```yaml
141
149
name: Dependabot auto-merge
142
-
on: pull_request
150
+
on: pull_request_target
143
151
permissions:
144
152
pull-requests: write
145
153
contents: write
@@ -166,7 +174,7 @@ For example, if you want to flag all production dependency updates with a label:
166
174
167
175
```yaml
168
176
name: Dependabot auto-label
169
-
on: pull_request
177
+
on: pull_request_target
170
178
permissions:
171
179
pull-requests: write
172
180
issues: write
@@ -225,12 +233,12 @@ jobs:
225
233
<details><summary>:book: Release guide</summary>
226
234
<p>
227
235
228
-
## Dependabot PR's
236
+
## Dependabot PRs
229
237
230
-
- We expect Dependabot PRs to be passing CI and have any changes to the `dist/` folder built for production dependencies
231
-
- Some development dependencies may fail the `dist/` check if they modify the Typescript compilation, these should be updated manually via `npm run build`. See the [`dependabot-build`](https://github.com/dependabot/fetch-metadata/blob/main/.github/workflows/dependabot-build.yml) action for details.
238
+
- We expect Dependabot PRs to be passing CI and have any changes to the `dist/` folder built for production dependencies
239
+
- Some development dependencies may fail the `dist/` check if they modify the TypeScript compilation, these should be updated manually via `npm run build`. See the [`dependabot-build`](https://github.com/dependabot/fetch-metadata/blob/main/.github/workflows/dependabot-build.yml) action for details.
232
240
233
-
## Tagging a new release
241
+
## Tagging a new release
234
242
235
243
Publish a new release by running the [`Release - Bump Version`](https://github.com/dependabot/fetch-metadata/actions/workflows/release-bump-version.yml) workflow and following the instructions on the job summary.
0 commit comments