CI: Add Dependabot go workspace action (#96064)

This commit is contained in:
Todd Treece 2024-11-07 20:14:04 -05:00 committed by GitHub
parent 4e318e6285
commit 0b06dca472
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 59 additions and 0 deletions

1
.github/CODEOWNERS vendored
View File

@ -741,6 +741,7 @@ embed.go @grafana/grafana-as-code
/.github/workflows/i18n-crowdin-upload.yml @grafana/grafana-frontend-platform
/.github/workflows/i18n-crowdin-download.yml @grafana/grafana-frontend-platform
/.github/workflows/pr-go-workspace-check.yml @grafana/grafana-app-platform-squad
/.github/workflows/pr-dependabot-update-go-workspace.yml @grafana/grafana-app-platform-squad
/.github/workflows/pr-k8s-codegen-check.yml @grafana/grafana-app-platform-squad
/.github/workflows/go_lint.yml @grafana/grafana-backend-services-squad
/.github/workflows/trivy-scan.yml @grafana/grafana-backend-services-squad

View File

@ -0,0 +1,49 @@
name: "Update Go Workspace for Dependabot PRs"
on:
pull_request:
branches: [main]
paths:
- .github/workflows/pr-dependabot-update-go-workspace.yml
- go.mod
- go.sum
- go.work
- go.work.sum
- '**/go.mod'
- '**/go.sum'
- '**.go'
permissions:
contents: write
jobs:
update:
runs-on: "ubuntu-latest"
if: ${{ github.actor == 'dependabot[bot]' }}
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Set go version
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Update workspace
run: make update-workspace
- name: Commit and push workspace changes
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
if ! git diff --exit-code --quiet; then
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local --add --bool push.autoSetupRemote true
echo "Committing and pushing workspace changes"
git remote
git branch -l
git commit -a -m "update workspace"
git push origin $BRANCH_NAME
fi

View File

@ -4,6 +4,15 @@ on:
workflow_dispatch:
pull_request:
branches: [main]
paths:
- .github/workflows/pr-go-workspace-check.yml
- go.mod
- go.sum
- go.work
- go.work.sum
- '**/go.mod'
- '**/go.sum'
- '**.go'
jobs:
check: