Run go mod tidy and create PullRequest on GitHub Actions
https://github.com/marketplace/actions/go-mod-tidy-pr
This is inspired by circleci-bundle-update-pr
Now, Dependabot officially supports go mod tidy.
https://github.blog/changelog/2020-10-19-dependabot-go-mod-tidy-and-vendor-support/
So this action is deprecated.
# .github/workflows/go-mod-tidy-pr.yml
name: go-mod-tidy-pr
on:
schedule:
- cron: "0 0 * * 1" # Weekly build
workflow_dispatch:
jobs:
go-mod-tidy-pr:
name: go-mod-tidy-pr
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run go-mod-tidy-pr
uses: sue445/go-mod-tidy-pr@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_user_name: GitHub Actions
git_user_email: [email protected]
# reviewer: foo
# assign: foo
# milestone: some_milestone
# labels: go-mod-tidy
# draft: "true"
# go_mod_directory: "/dir/to/go-mod"
# go_version: 1.14.2
# debug: "true"
# duplicate: "true"
# timezone: Asia/Tokyogithub_tokenRequired- GitHub Token
git_user_nameRequired- Username for commit
git_user_emailRequired- E-mail for commit
base- The base branch in the "[OWNER:]BRANCH" format. Defaults to the default branch of the upstream repository (usually "master").
- See https://hub.github.com/hub-pull-request.1.html
reviewer- A comma-separated list (no spaces around the comma) of GitHub handles to request a review from.
- See https://hub.github.com/hub-pull-request.1.html
assign- A comma-separated list (no spaces around the comma) of GitHub handles to assign to this pull request.
- See https://hub.github.com/hub-pull-request.1.html
milestone- The milestone name to add to this pull request. Passing the milestone number is deprecated.
- See https://hub.github.com/hub-pull-request.1.html
labels- A comma-separated list (no spaces around the comma) of labels to add to this pull request. Labels will be created if they do not already exist.
- See https://hub.github.com/hub-pull-request.1.html
draft- Create the pull request as a draft.
- See https://hub.github.com/hub-pull-request.1.html
go_mod_directoryRequired- Directory where
go.modis located - Default.
.
- Directory where
go_version- Go version to be used. Defaults to the latest version.
debug- Whether print debug logging
duplicate- Whether create PullRequest even if it has already existed
timezone- Timezone to be used if set (e.g.
Asia/Tokyo)
- Timezone to be used if set (e.g.
If you configure Pull Request build on GitHub Action, builds doesn't trigger when go-mod-tidy-pr creates Pull Request.
The workaround is one of the following.
- Use GitHub App Token instead of
secrets.GITHUB_TOKEN(RECOMMENDED)- Required permission: Pull requests (Read & write)
- Use personal access token instead of
secrets.GITHUB_TOKEN - Use CI other than GitHub Action on Pull Request build
https://github.com/sue445/go-mod-tidy-pr/blob/master/CHANGELOG.md
