-
Notifications
You must be signed in to change notification settings - Fork 294
Add Dependabot Tidy workflow for managing Go module dependencies #2810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
95d8869
4c236f0
26443e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Dependabot bumps `/` and `/test` as independent modules, but `/test` inherits the | ||
| # root's dependencies via `replace ... => ../`, so a root bump leaves test/go.{mod,sum} | ||
| # (and vendoring) stale. This re-tidies both and pushes the fix back to the PR branch. | ||
| name: Dependabot Tidy | ||
|
|
||
| on: pull_request | ||
|
|
||
| # contents:write lets the built-in GITHUB_TOKEN push the fix; no PAT/App token needed. | ||
| permissions: | ||
| contents: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| tidy: | ||
| if: github.actor == 'dependabot[bot]' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| ref: ${{ github.head_ref }} | ||
| show-progress: false | ||
|
|
||
| - name: Install Go | ||
| uses: ./.github/actions/setup-go | ||
| with: | ||
| fill-module-cache: true | ||
|
|
||
| - name: Run go mod tidy and vendor | ||
|
rawahars marked this conversation as resolved.
Outdated
|
||
| run: | | ||
| go mod tidy -e | ||
| go mod vendor -e | ||
| (cd test && go mod tidy -e) | ||
|
|
||
| - name: Commit and push if changed | ||
| run: | | ||
| git add -A go.mod go.sum vendor test/go.mod test/go.sum | ||
| if git diff --cached --quiet; then | ||
| echo 'modules already tidy, nothing to push' | ||
| exit 0 | ||
| fi | ||
| git config user.name 'dependabot[bot]' | ||
| git config user.email '49699333+dependabot[bot]@users.noreply.github.com' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it feels weird to impersonate dependabot (or take a dependency on its bot id/email remaining the same)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds good! I made the change to attribute the commit to github actions bot instead. |
||
| git commit -s -m 'go mod tidy && go mod vendor' | ||
| git push origin HEAD:"${{ github.head_ref }}" | ||
Uh oh!
There was an error while loading. Please reload this page.