Skip to content

Commit 71adeb7

Browse files
author
Ryan Lymburner
authored
Merge branch 'main' into fix-acces-log-ns-panic
2 parents 56f4569 + f5a3a6e commit 71adeb7

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed

.github/dependabot-readme.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Dependabot Configuration for Go Modules
2+
3+
This repository is configured to use Dependabot for automated dependency updates with `go mod tidy` support.
4+
5+
## Configuration Files
6+
7+
1. `.github/dependabot.yml` - Configures Dependabot to check for Go module updates weekly
8+
2. `.github/workflows/dependabot-go-mod-tidy.yml` - GitHub Actions workflow that runs `go mod tidy` on Dependabot PRs
9+
10+
## How It Works
11+
12+
1. Dependabot creates PRs to update Go dependencies according to the schedule in `dependabot.yml`
13+
2. When a PR is created that modifies `go.mod` or `go.sum`, the workflow is triggered
14+
3. The workflow checks if the PR was created by Dependabot
15+
4. If so, it runs `go mod tidy` and commits any changes back to the PR
16+
17+
## Required Repository Settings
18+
19+
For the workflow to function properly, you need to configure the repository to allow Dependabot to trigger workflows with write permissions:
20+
21+
1. Go to the repository on GitHub
22+
2. Navigate to Settings > Code and automation > Actions > General
23+
3. Scroll down to "Workflow permissions"
24+
4. Enable "Read and write permissions"
25+
5. Check "Allow GitHub Actions to create and approve pull requests"
26+
6. Save changes
27+
28+
Additionally, you need to configure Dependabot to have write access to PRs:
29+
30+
1. Go to the repository on GitHub
31+
2. Navigate to Settings > Code and automation > Actions > General
32+
3. Scroll down to "Workflow permissions from pull requests"
33+
4. Select "Allow Dependabot to run workflows"
34+
5. Save changes
35+
36+
## Troubleshooting
37+
38+
If the workflow isn't running or isn't able to commit changes:
39+
40+
1. Check that the repository settings are configured as described above
41+
2. Verify that the PR was created by Dependabot
42+
3. Check the workflow run logs for any errors

.github/dependabot.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
# Enable go mod tidy after updates
8+
ignore:
9+
- dependency-name: "*"
10+
update-types: ["version-update:semver-patch"]
11+
commit-message:
12+
prefix: "chore"
13+
include: "scope"
14+
labels:
15+
- "dependencies"
16+
- "go"
17+
# Add the go mod tidy command
18+
gomod:
19+
update-tool: "go mod tidy"
20+
21+
- package-ecosystem: "gomod"
22+
directory: "/test"
23+
schedule:
24+
interval: "weekly"
25+
ignore:
26+
- dependency-name: "*"
27+
update-types: ["version-update:semver-patch"]
28+
commit-message:
29+
prefix: "chore"
30+
include: "scope"
31+
labels:
32+
- "dependencies"
33+
- "go"
34+
gomod:
35+
update-tool: "go mod tidy"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Dependabot Go Mod Tidy
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'go.mod'
7+
- 'go.sum'
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
go-mod-tidy:
15+
runs-on: ubuntu-latest
16+
if: ${{ github.actor == 'dependabot[bot]' }}
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
with:
21+
ref: ${{ github.head_ref }}
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Setup Go
25+
uses: actions/setup-go@v4
26+
with:
27+
go-version: '1.x'
28+
29+
- name: Run go mod tidy
30+
run: |
31+
go mod tidy
32+
33+
- name: Check for changes
34+
id: git-check
35+
run: |
36+
git status --porcelain
37+
if [ -n "$(git status --porcelain)" ]; then
38+
echo "changes=true" >> $GITHUB_OUTPUT
39+
else
40+
echo "changes=false" >> $GITHUB_OUTPUT
41+
fi
42+
43+
- name: Commit and push changes
44+
if: steps.git-check.outputs.changes == 'true'
45+
run: |
46+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
47+
git config --local user.name "github-actions[bot]"
48+
git add go.mod go.sum
49+
git commit -m "Run go mod tidy for Dependabot PR"
50+
git push

0 commit comments

Comments
 (0)