|
| 1 | +name: Update Protobufs |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: '0 0 * * *' |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - protobuf-bot |
| 8 | +jobs: |
| 9 | + protobuf: |
| 10 | + name: Update Protobufs |
| 11 | + runs-on: ubuntu-latest |
| 12 | + env: |
| 13 | + GameTracking_dir: /tmp/GameTracking-CSGO |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + - name: Download latest Protobufs |
| 17 | + run: | |
| 18 | + git clone https://github.com/SteamDatabase/GameTracking-CSGO.git $GameTracking_dir |
| 19 | + cp $GameTracking_dir/Protobufs/{cstrike15_*.proto,engine_gcmessages.proto,netmessages.proto,steammessages.proto} pkg/demoinfocs/msg/proto |
| 20 | +
|
| 21 | + if [[ ! `git status --porcelain` ]]; then |
| 22 | + echo '::set-env name=PROTOBUFS_CHANGED::false' |
| 23 | + exit 0 |
| 24 | + else |
| 25 | + echo '::set-env name=PROTOBUFS_CHANGED::true' |
| 26 | + fi |
| 27 | +
|
| 28 | + - name: Install Go |
| 29 | + if: env.PROTOBUFS_CHANGED == 'true' |
| 30 | + uses: actions/setup-go@v2 |
| 31 | + with: |
| 32 | + go-version: 1.14.x |
| 33 | + |
| 34 | + - name: Install Protobuf tools |
| 35 | + if: env.PROTOBUFS_CHANGED == 'true' |
| 36 | + run: | |
| 37 | + sudo apt-get update |
| 38 | + sudo apt-get install unzip |
| 39 | +
|
| 40 | + wget -O /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.12.2/protoc-3.12.2-linux-x86_64.zip |
| 41 | + unzip /tmp/protoc.zip -d /tmp/protoc |
| 42 | +
|
| 43 | + GO111MODULE=off go get -u github.com/gogo/protobuf/protoc-gen-gogofaster |
| 44 | +
|
| 45 | + - name: Generate Go code |
| 46 | + if: env.PROTOBUFS_CHANGED == 'true' |
| 47 | + run: | |
| 48 | + cd pkg/demoinfocs/msg |
| 49 | + sed -i '1s/^/option go_package = "msg";\n\n/' proto/cstrike15_usermessages.proto |
| 50 | + sed -i '1s/^/option go_package = "msg";\n\n/' proto/cstrike15_gcmessages.proto |
| 51 | + sed -i '1s/^/option go_package = "msg";\n\n/' proto/engine_gcmessages.proto |
| 52 | + sed -i '1s/^/option go_package = "msg";\n\n/' proto/netmessages.proto |
| 53 | + sed -i '1s/^/option go_package = "msg";\n\n/' proto/steammessages.proto |
| 54 | +
|
| 55 | + export PATH=/tmp/protoc/bin:$PATH |
| 56 | + protoc -I=proto --gogofaster_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:. proto/*.proto |
| 57 | +
|
| 58 | + - name: Commit changes |
| 59 | + if: env.PROTOBUFS_CHANGED == 'true' |
| 60 | + run: | |
| 61 | + commit_sha=$(pushd $GameTracking_dir > /dev/null && git rev-parse HEAD && popd > /dev/null) |
| 62 | + branch=update-protobufs/$commit_sha |
| 63 | + echo "::set-env name=BRANCH::$branch" |
| 64 | + echo "::set-env name=COMMIT_SHA::$commit_sha" |
| 65 | +
|
| 66 | + - name: Create Pull Request |
| 67 | + id: pr |
| 68 | + if: env.PROTOBUFS_CHANGED == 'true' |
| 69 | + uses: peter-evans/create-pull-request@v2 |
| 70 | + with: |
| 71 | + title: "protobuf: updated to ${{ env.COMMIT_SHA }}" |
| 72 | + base: master |
| 73 | + branch: ${{ env.BRANCH }} |
| 74 | + commit-message: | |
| 75 | + protobuf: updated to ${{ env.COMMIT_SHA }} |
| 76 | +
|
| 77 | + see https://github.com/SteamDatabase/GameTracking-CSGO |
| 78 | + body: | |
| 79 | + see https://github.com/SteamDatabase/GameTracking-CSGO |
| 80 | +
|
| 81 | + - name: Print PR outputs |
| 82 | + if: env.PROTOBUFS_CHANGED == 'true' |
| 83 | + run: | |
| 84 | + echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}" |
| 85 | + echo "Pull Request Number - ${{ steps.pr.outputs.pull-request-number }}" |
0 commit comments