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 "Grot" git config --local user.email "grot@grafana.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