Skip to content

Update OBS websocket protocol version #422

Update OBS websocket protocol version

Update OBS websocket protocol version #422

name: Update OBS websocket protocol version
on:
workflow_dispatch:
schedule:
- cron: 0 0 * * *
jobs:
update:
name: update protocol version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.CATHY_CLOUD_APP_ID }}
private_key: ${{ secrets.CATHY_CLOUD_APP_PRIVATE_KEY }}
- uses: magnetikonline/action-golang-cache@v5
with:
go-version-file: go.mod
- name: create bump version protocol PR
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
base: main
run: |
if ! ./script/bump-protocol-version.sh; then exit 0; fi
bump=$(cat /tmp/.goobs.protocol.bump)
next=$(cat /tmp/.goobs.protocol.next)
branch="bump-protocol-version"
message="Bump OBS websocket protocol to $next"
body='
There was a new v5 tag in [obsproject/obs-websocket](https://github.com/obsproject/obs-websocket).
This PR may or may not contain any actual changes to the generated code.
'
git config --global user.name "cathy-cloud[bot]"
git config --global user.email "154095190+cathy-cloud[bot]@users.noreply.github.com"
git checkout -b "$branch"
git add .
git commit -m "$message"
git push -fu origin "$branch"
pr=$(gh pr list -s open -A 'cathy-cloud[bot]' -L 1 --json number,headRefName -q .[].number)
if [ -n "$pr" ]; then
echo "Open PR $pr for $branch already exists"
else
echo "Creating PR for $branch"
pr=$(
gh pr create \
--base "${{ env.base }}" \
--title "$message" \
--label "$bump" \
--label protocol \
--body "$body"
)
fi
echo "Trying to auto merge..."
attempt=0
while :; do
if [ "$attempt" -eq 10 ]; then exit 1; fi
if gh pr merge --squash --auto "$pr"; then break; fi
attempt=$((attempt+1))
sleep 10
done
echo "Waiting until it's merged in..."
while :; do
state=$(gh pr view "$pr" --json state -q .state)
if [ "$state" = MERGED ]; then break; fi
sleep 10
done
echo "PR was merged in!"