From ca31cda3ad171c4ffc3b7adb1595df5569743855 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Sun, 6 Mar 2022 09:42:24 +1100 Subject: [PATCH] Automatically update the controller version (#57) Create a new GitHub Actions workflow to submit a pull request for new controller versions. --- .github/workflows/ci.yaml | 4 ++-- .github/workflows/generate.yaml | 31 +++++++++++++++++++++++++++++++ unifi/{gen.go => fields.go} | 0 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/generate.yaml rename unifi/{gen.go => fields.go} (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0f3be5e..593af53 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,9 +42,9 @@ jobs: - uses: "actions/setup-go@v2" with: go-version: "${{ env.GO_VERSION }}" - - run: "go get golang.org/x/tools/cmd/stringer" + - run: "go install golang.org/x/tools/cmd/stringer" - - run: "go generate ./..." + - run: "go generate unifi/device.go" - run: "git diff --compact-summary --exit-code" lint: diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml new file mode 100644 index 0000000..95f3aec --- /dev/null +++ b/.github/workflows/generate.yaml @@ -0,0 +1,31 @@ +--- +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: {} + +env: + GO_VERSION: "^1.16" + +jobs: + fields: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/setup-go@v2" + with: + go-version: "${{ env.GO_VERSION }}" + + - uses: "actions/checkout@v2" + - uses: "actions/cache@v2" + with: + path: "~/go/pkg/mod" + key: "${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}" + restore-keys: | + ${{ runner.os }}-gomod- + + # TODO: Automatically merge the PR if tests pass. + - run: "go generate unifi/fields.go" + - uses: "peter-evans/create-pull-request@v3" + with: + delete-branch: true + title: "Update to latest controller version" diff --git a/unifi/gen.go b/unifi/fields.go similarity index 100% rename from unifi/gen.go rename to unifi/fields.go