name: Build protos on: pull_request: paths: - '*.proto' - '**/*.proto' permissions: contents: write jobs: build: name: Build Protobufs runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v7 with: fetch-depth: 0 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 with: go-version: '1.27' - name: Install protoc run: | 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@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 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"