Skip to content
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

chore: add friendly reminders if go mod tidy needs to be run #1001

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Changes from all commits
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
41 changes: 41 additions & 0 deletions .github/workflows/friendly-reminders.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 👋 Friendly Reminders

on:
pull_request:
branches: main

jobs:
job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Extract go version
id: go-version
run: |
echo "go-version=$(go work edit --json | jq -r '.Go')" >>$GITHUB_OUTPUT
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.go-version.outputs.go-version }}

- name: Check Go Mod Tidy
id: go-mod-tidy
run: |
# iterate over work file, cd and run go mod tidy
for line in $(go work edit --json | jq -r '.Use.[].DiskPath'); do
(cd $line && go mod tidy)
done
# check if any changes were made
echo $(git status --porcelain) >> $GITHUB_OUTPUT

- name: Post comment if go.mod was changed
if: steps.go-mod-tidy.outputs.stdout != ''
uses: actions/github-script@v7
with:
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Friendly reminder: go.mod was changed. Make sure to run `go mod tidy`!\n\n' +
'```\n${{ steps.go-mod-tidy.outputs.stdout }}\n```'
})
Loading