Skip to content

Update Amazon IVS SDKs #97

Update Amazon IVS SDKs

Update Amazon IVS SDKs #97

name: Update Amazon IVS SDKs
on:
schedule:
- cron: '0 0 * * *' # Run daily at midnight UTC
workflow_dispatch: # Allow manual triggering
jobs:
update-ivs-sdks:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Check for Player SDK updates
id: check-player
run: |
# Extract current version from index.html
CURRENT_VERSION=$(grep -oP 'player\.live-video\.net/\K[0-9]+\.[0-9]+\.[0-9]+' web-ui/public/index.html)
echo "Current Player SDK version: $CURRENT_VERSION"
# Get latest version from npm
LATEST_VERSION=$(npm view amazon-ivs-player version)
echo "Latest Player SDK version: $LATEST_VERSION"
# Compare versions
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "Player SDK update available: $CURRENT_VERSION -> $LATEST_VERSION"
echo "has_update=true" >> $GITHUB_OUTPUT
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "new_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
# Update the script src in index.html
sed -i "s|player\.live-video\.net/$CURRENT_VERSION|player.live-video.net/$LATEST_VERSION|g" web-ui/public/index.html
else
echo "No Player SDK update available"
echo "has_update=false" >> $GITHUB_OUTPUT
fi
- name: Check for Chat Messaging SDK updates
id: check-chat
run: |
cd web-ui
# Extract current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').dependencies['amazon-ivs-chat-messaging']" | sed 's/[\^~]//g')
echo "Current Chat Messaging SDK version: $CURRENT_VERSION"
# Get latest version from npm
LATEST_VERSION=$(npm view amazon-ivs-chat-messaging version)
echo "Latest Chat Messaging SDK version: $LATEST_VERSION"
# Compare versions
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "Chat Messaging SDK update available: $CURRENT_VERSION -> $LATEST_VERSION"
echo "has_update=true" >> $GITHUB_OUTPUT
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "new_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
# Update package.json
npm install amazon-ivs-chat-messaging@$LATEST_VERSION --save-exact
# Change back to caret notation to match existing style
sed -i "s|\"amazon-ivs-chat-messaging\": \"$LATEST_VERSION\"|\"amazon-ivs-chat-messaging\": \"^$LATEST_VERSION\"|g" package.json
else
echo "No Chat Messaging SDK update available"
echo "has_update=false" >> $GITHUB_OUTPUT
fi
- name: Prepare PR details
id: pr-details
run: |
PLAYER_UPDATE="${{ steps.check-player.outputs.has_update }}"
CHAT_UPDATE="${{ steps.check-chat.outputs.has_update }}"
if [ "$PLAYER_UPDATE" = "true" ] || [ "$CHAT_UPDATE" = "true" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
# Build commit message and PR title
if [ "$PLAYER_UPDATE" = "true" ] && [ "$CHAT_UPDATE" = "true" ]; then
TITLE="chore: update Amazon IVS Player SDK to ${{ steps.check-player.outputs.new_version }} and Chat Messaging SDK to ${{ steps.check-chat.outputs.new_version }}"
BODY="This PR updates both Amazon IVS SDKs:
- **Player SDK**: ${{ steps.check-player.outputs.current_version }} → ${{ steps.check-player.outputs.new_version }}
- **Chat Messaging SDK**: ${{ steps.check-chat.outputs.current_version }} → ${{ steps.check-chat.outputs.new_version }}
## Changes
- Updated Player SDK CDN URL in \`web-ui/public/index.html\`
- Updated Chat Messaging SDK version in \`web-ui/package.json\`
This update was automatically generated by the dependency update workflow."
elif [ "$PLAYER_UPDATE" = "true" ]; then
TITLE="chore: update Amazon IVS Player SDK to ${{ steps.check-player.outputs.new_version }}"
BODY="This PR updates the Amazon IVS Player SDK from ${{ steps.check-player.outputs.current_version }} to ${{ steps.check-player.outputs.new_version }}.
## Changes
- Updated Player SDK CDN URL in \`web-ui/public/index.html\`
This update was automatically generated by the dependency update workflow."
else
TITLE="chore: update amazon-ivs-chat-messaging to ${{ steps.check-chat.outputs.new_version }}"
BODY="This PR updates the amazon-ivs-chat-messaging package from ${{ steps.check-chat.outputs.current_version }} to ${{ steps.check-chat.outputs.new_version }}.
## Changes
- Updated Chat Messaging SDK version in \`web-ui/package.json\`
This update was automatically generated by the dependency update workflow."
fi
# Use environment files for multiline output
echo "PR_TITLE=$TITLE" >> $GITHUB_ENV
echo "PR_BODY<<EOF" >> $GITHUB_ENV
echo "$BODY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: steps.pr-details.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v6
with:
commit-message: ${{ env.PR_TITLE }}
title: ${{ env.PR_TITLE }}
body: ${{ env.PR_BODY }}
branch: dependency-update/ivs-sdks
delete-branch: true
labels: dependencies