Created
April 1, 2020 15:28
-
-
Save ydnar/88d39d72e9eb4f9ee5ef81421a1a2f58 to your computer and use it in GitHub Desktop.
Fix Dependabot Go modules PRs
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
name: Dependabot Go modules | |
on: | |
pull_request: | |
paths: | |
- "go.mod" | |
- "go.sum" | |
jobs: | |
dependabot: | |
name: Check Dependabot’s work | |
if: startsWith(github.ref, 'refs/heads/dependabot/') || startsWith(github.head_ref, 'dependabot/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.SEPARATE_GITHUB_ACCESS_TOKEN }} | |
ref: ${{ github.head_ref }} # Ensures we check out the branch, not the PR ref | |
submodules: recursive | |
- name: Set up Go | |
uses: actions/setup-go@v2-beta | |
with: | |
go-version: ^1 | |
- name: Cache Go modules | |
uses: actions/cache@v1 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-mod- | |
- name: Download Go modules | |
run: | | |
go mod download | |
go mod tidy | |
go test -i -mod=readonly -race ./... | |
- name: Verify repo is unchanged | |
run: git diff --exit-code HEAD | |
- name: Create fixup commit | |
if: failure() | |
run: | | |
git config --global user.email [email protected] | |
git config --global user.name dependabot-fixup | |
git add go.mod go.sum | |
git commit -m "go.{mod,sum}: fixup commit for Dependabot" | |
git push origin -u HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment