Update Protobufs #1250
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: Update Protobufs | |
on: | |
workflow_dispatch: {} | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
protobuf: | |
name: Update Protobufs | |
runs-on: ubuntu-latest | |
env: | |
GameTracking_dir: /tmp/GameTracking-CSGO | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Download latest Protobufs | |
run: | | |
git clone --depth=1 https://github.com/SteamDatabase/GameTracking-CSGO.git $GameTracking_dir | |
cp $GameTracking_dir/Protobufs/{cstrike15_*.proto,engine_gcmessages.proto,netmessages.proto,steammessages.proto,gcsdk_gcmessages.proto,networkbasetypes.proto,network_connection.proto} pkg/demoinfocs/msg/proto | |
if [[ ! `git status --porcelain` ]]; then | |
echo "PROTOBUFS_CHANGED=false" >> $GITHUB_ENV | |
exit 0 | |
else | |
echo "PROTOBUFS_CHANGED=true" >> $GITHUB_ENV | |
fi | |
- name: Install Go | |
if: env.PROTOBUFS_CHANGED == 'true' | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.21.x | |
- name: Install Protobuf tools | |
if: env.PROTOBUFS_CHANGED == 'true' | |
run: | | |
sudo apt-get update | |
sudo apt-get install unzip | |
wget -O /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v21.3/protoc-21.3-linux-x86_64.zip | |
unzip /tmp/protoc.zip -d /tmp/protoc | |
go install google.golang.org/protobuf/cmd/[email protected] | |
- name: Generate Go code | |
if: env.PROTOBUFS_CHANGED == 'true' | |
run: | | |
cd pkg/demoinfocs/msg | |
export PATH=/tmp/protoc/bin:$PATH | |
./generate.sh | |
- name: Commit changes | |
if: env.PROTOBUFS_CHANGED == 'true' | |
run: | | |
commit_sha=$(pushd $GameTracking_dir > /dev/null && git rev-parse HEAD && popd > /dev/null) | |
echo "COMMIT_SHA=$commit_sha" >> $GITHUB_ENV | |
- name: Create Pull Request | |
id: pr | |
if: env.PROTOBUFS_CHANGED == 'true' | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} | |
title: "protobuf: updated to ${{ env.COMMIT_SHA }}" | |
base: master | |
branch: update-protobufs | |
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
commit-message: | | |
protobuf: updated to ${{ env.COMMIT_SHA }} | |
see https://github.com/SteamDatabase/GameTracking-CSGO | |
body: | | |
see https://github.com/SteamDatabase/GameTracking-CSGO | |
- name: Print PR outputs | |
if: env.PROTOBUFS_CHANGED == 'true' | |
run: | | |
echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}" | |
echo "Pull Request Number - ${{ steps.pr.outputs.pull-request-number }}" |