-
Notifications
You must be signed in to change notification settings - Fork 8
63 lines (52 loc) · 2.03 KB
/
auto-update-royco-sdk.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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