b9a7c2cabc
Changes: - Update frequency: weekly → daily (06:00 UTC) - Add retry with exponential backoff (3 attempts per source) - Add multiple source endpoints (sw.js + bootstrap page) - Add version validation (sanity checks on revision numbers) - Add fetch timeout to prevent hanging - Add detailed logging for debugging - Simplify workflow to only update baileys-version.json This makes the version update more reliable and responsive to WhatsApp Web changes.
106 lines
3.1 KiB
YAML
106 lines
3.1 KiB
YAML
name: Update WhatsApp Version
|
||
|
||
on:
|
||
schedule:
|
||
# Run daily at 06:00 UTC (when WhatsApp typically deploys updates)
|
||
- cron: '0 6 * * *'
|
||
workflow_dispatch:
|
||
inputs:
|
||
force:
|
||
description: 'Force update even if version is the same'
|
||
required: false
|
||
default: 'false'
|
||
|
||
permissions:
|
||
contents: write
|
||
pull-requests: write
|
||
|
||
jobs:
|
||
update-version:
|
||
runs-on: ubuntu-latest
|
||
timeout-minutes: 10
|
||
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
|
||
- name: Setup Node and Corepack
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version: 20.x
|
||
|
||
- name: Enable Corepack and Set Yarn Version
|
||
run: |
|
||
corepack enable
|
||
corepack prepare yarn@4.x --activate
|
||
|
||
- name: Restore Yarn Cache
|
||
uses: actions/cache@v4
|
||
id: yarn-cache
|
||
with:
|
||
path: .yarn/cache
|
||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-yarn-
|
||
|
||
- name: Install packages
|
||
run: yarn install --immutable
|
||
|
||
- name: Update WhatsApp Web Version
|
||
id: update_version
|
||
run: yarn update:version
|
||
|
||
- name: Check for changes
|
||
id: check_changes
|
||
run: |
|
||
if git diff --quiet; then
|
||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||
else
|
||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||
fi
|
||
|
||
- name: Create Pull Request
|
||
if: steps.check_changes.outputs.has_changes == 'true'
|
||
env:
|
||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||
run: |
|
||
BRANCH_NAME="update-version/stable"
|
||
|
||
# Configure git
|
||
git config user.name "github-actions[bot]"
|
||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||
|
||
# Check if branch exists and delete it
|
||
git push origin --delete "$BRANCH_NAME" 2>/dev/null || true
|
||
|
||
# Create new branch, commit, and push
|
||
git checkout -b "$BRANCH_NAME"
|
||
|
||
# Only add the single source of truth file
|
||
git add src/Defaults/baileys-version.json
|
||
git commit -m "chore: update WhatsApp Web version"
|
||
git push origin "$BRANCH_NAME"
|
||
|
||
# Create PR using GitHub CLI
|
||
gh pr create \
|
||
--title "chore: update WhatsApp Web version" \
|
||
--body "Automated WhatsApp Web version update.
|
||
|
||
This PR updates the WhatsApp Web client revision to the latest version fetched from \`web.whatsapp.com\`.
|
||
|
||
**Single source of truth:**
|
||
- \`src/Defaults/baileys-version.json\` (other files import from here)
|
||
|
||
**Update frequency:** Daily at 06:00 UTC" \
|
||
--base master \
|
||
--head "$BRANCH_NAME" || echo "PR already exists or could not be created"
|
||
|
||
- name: Summary
|
||
run: |
|
||
echo "### WhatsApp Version Update" >> $GITHUB_STEP_SUMMARY
|
||
echo "" >> $GITHUB_STEP_SUMMARY
|
||
if [ "${{ steps.check_changes.outputs.has_changes }}" == "true" ]; then
|
||
echo "✅ New version detected and PR created" >> $GITHUB_STEP_SUMMARY
|
||
else
|
||
echo "ℹ️ Already up to date" >> $GITHUB_STEP_SUMMARY
|
||
fi
|