From ce2c54acf260d3915dbf2433e520e264ad6a9bd9 Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 17:11:48 +0900 Subject: [PATCH] update CI workflow to install specific protoc version and enhance generated Protobufs handling --- .github/workflows/build.yml | 34 +++++++++++++++++++++++++--------- README.md | 10 +++++++--- deployment.proto | 1 - 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 80ac9c6..66bf87c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v7 with: fetch-depth: 0 - ref: ${{ github.ref }} + ref: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.head.sha || github.sha }} - name: Set up Go uses: actions/setup-go@v7 @@ -26,21 +26,37 @@ jobs: - name: Install protoc run: | - sudo apt-get update - sudo apt-get install -y protobuf-compiler + curl --fail --location --silent --show-error \ + --output "$RUNNER_TEMP/protoc.zip" \ + https://github.com/protocolbuffers/protobuf/releases/download/v36.2/protoc-36.2-linux-x86_64.zip + unzip -q "$RUNNER_TEMP/protoc.zip" -d "$RUNNER_TEMP/protoc" + echo "$RUNNER_TEMP/protoc/bin" >> "$GITHUB_PATH" - name: Install protoc-gen-go run: | - go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.12 - name: Generate Protobufs run: | make proto - name: Commit and push changes + env: + HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} + HEAD_REF: ${{ github.event.pull_request.head.ref }} + REPOSITORY: ${{ github.repository }} run: | - git config --global user.name "actions[bot]" - git config --global user.email "noreply@beejay.kim" - git add . - git commit -m "Update generated Protobufs" || echo "No changes to commit" - git push origin ${{ github.ref }} || echo "No changes to push" + git add -- '*.pb.go' + if git diff --cached --quiet; then + exit 0 + fi + + if [ "$HEAD_REPOSITORY" != "$REPOSITORY" ]; then + echo "::error::Generated protobufs are out of date. Run make proto and commit the changes." + exit 1 + fi + + git config user.name "actions[bot]" + git config user.email "noreply@beejay.kim" + git commit -m "Update generated Protobufs" + git push origin "HEAD:refs/heads/$HEAD_REF" diff --git a/README.md b/README.md index ace2975..798f358 100644 --- a/README.md +++ b/README.md @@ -55,13 +55,17 @@ The module requires Go 1.27 and `google.golang.org/protobuf`. ## Regenerating Go code -Install `protoc` and the Go generator, and ensure both executables are on -`PATH`: +Install `protoc` 36.2 using the [official installation +instructions](https://protobuf.dev/installation/), and ensure it and the Go +generator are on `PATH`: ```sh +protoc --version go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.12 make proto ``` `make proto` regenerates the Go files from both schemas. Commit the updated -`.pb.go` files together with any schema changes. \ No newline at end of file +`.pb.go` files together with any schema changes. The workflow pushes generated +files to same-repository pull request branches; for pull requests from forks, +it reports an error if generated files are out of date. \ No newline at end of file diff --git a/deployment.proto b/deployment.proto index 60a5c9e..5a478c3 100644 --- a/deployment.proto +++ b/deployment.proto @@ -6,7 +6,6 @@ option go_package = "beejay.kim/fog/model"; enum DeploymentAction { STOP = 0; START = 1; - CLEANUP = 2; } message GlobalEnvironment {