Update Royco SDK #3522
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 Royco SDK | |
# Add these permission settings | |
permissions: | |
contents: write # For creating releases and pushing code | |
pull-requests: write # For creating pull requests | |
packages: write # For publishing packages | |
on: | |
schedule: | |
# Run every 15 minutes | |
- cron: "*/15 * * * *" | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
check-and-update: | |
runs-on: ubuntu-latest | |
# Only run on main branch and specific repository | |
if: | | |
github.ref == 'refs/heads/main' && | |
github.repository == 'roycoprotocol/royco-frontend-template' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Check for package updates | |
run: | | |
# Get current version from package.json | |
CURRENT_VERSION=$(node -p "require('./package.json').dependencies.royco || '0.0.0'") | |
# Get latest version from npm | |
LATEST_VERSION=$(npm view royco version) | |
# Compare versions and update if needed | |
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | |
# Update package.json with new version (ignore scripts and suppress warnings) | |
npm install --save royco@latest --no-audit --ignore-scripts | |
# Check if there are actually changes to commit | |
if git diff --quiet package.json package-lock.json; then | |
echo "No changes to commit" | |
exit 0 | |
fi | |
# Configure Git | |
git config --global user.name 'GitHub Actions Bot' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
# Commit and push changes | |
git add package.json package-lock.json | |
git commit -m "chore(sdk): update royco to version ${LATEST_VERSION}" | |
git push | |
else | |
echo "Royco package is already up to date (${CURRENT_VERSION})" | |
exit 0 | |
fi |