Action Check 08 #4
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: Protobuf Compile Workflow | |
on: | |
push: | |
branches: | |
- release | |
jobs: | |
generate-code: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.x' | |
- name: Install protobuf and bufbuild | |
run: | | |
python -m pip install --upgrade pip | |
pip install grpcio-tools | |
curl -sSL https://github.com/bufbuild/buf/releases/download/v1.0.0-rc8/buf-Linux-x86_64 -o buf | |
chmod +x buf | |
sudo mv buf /usr/local/bin/buf | |
- name: Sync Directory Structures | |
run: | | |
rsync -a --include='*/' --exclude='*' origin/ python/ | |
rsync -a --include='*/' --exclude='*' origin/ typescript/ | |
- name: Generate Python Code | |
run: | | |
find origin -name '*.proto' -exec sh -c 'proto_path=${1#origin/}; mkdir -p `dirname "python/${proto_path%.proto}_pb2.py"`; python -m grpc_tools.protoc -I origin --python_out=python --grpc_python_out=python ${1}' _ {} \; | |
- name: Generate TypeScript Code | |
run: | | |
find origin -name '*.proto' -exec sh -c 'proto_path=${1#origin/}; mkdir -p `dirname "typescript/${proto_path%.proto}_pb.ts"`; buf generate --template buf.gen.yaml --path ${1} --output typescript' _ {} \; | |
- name: Commit and Push Changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: 'Auto-synced proto files and regenerated code' | |
add: 'python/** typescript/**' | |
default_author: github_actions |