Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/dependabot-tidy.yml
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.
Comment thread
rawahars marked this conversation as resolved.
Outdated
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
Comment thread
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'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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 }}"