-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] Add dependabot update workspace workflow (#554)
Adds a workflow to run `make update-workspace` on dependabot PRs and commit the result.
- Loading branch information
1 parent
55093e1
commit 3a88d77
Showing
7 changed files
with
119 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: "Update Go Workspace for Dependabot PRs" | ||
on: | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- .github/workflows/dependabot.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: Retrieve GitHub App secrets | ||
id: get-secrets | ||
uses: grafana/shared-workflows/actions/[email protected] | ||
with: | ||
repo_secrets: | | ||
APP_ID=grafana-go-workspace-bot:app-id | ||
APP_INSTALLATION_ID=grafana-go-workspace-bot:app-installation-id | ||
PRIVATE_KEY=grafana-go-workspace-bot:private-key | ||
- name: Generate GitHub App token | ||
id: generate_token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ env.APP_ID }} | ||
private-key: ${{ env.PRIVATE_KEY }} | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
token: ${{ steps.generate_token.outputs.token }} | ||
|
||
- name: Set go version | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: go.mod | ||
|
||
- name: Configure Git | ||
run: | | ||
git config --local user.email "${APP_INSTALLATION_ID}+grafana-go-workspace-bot[bot]@users.noreply.github.com" | ||
git config --local user.name "grafana-go-workspace-bot[bot]" | ||
git config --local --add --bool push.autoSetupRemote true | ||
- 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 | ||
echo "Committing and pushing workspace changes" | ||
git commit -a -m "update workspace" | ||
git push origin $BRANCH_NAME | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.