Skip to content

Commit 8b2e484

Browse files
committed
chore: wip
1 parent d8f353c commit 8b2e484

File tree

1 file changed

+114
-30
lines changed

1 file changed

+114
-30
lines changed

.github/workflows/buddy-update.yml

Lines changed: 114 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Standard Dependency Updates
1+
name: Buddy Update
22

33
on:
44
schedule:
5-
- cron: '0 9 * * 1,3,5'
6-
workflow_dispatch:
5+
- cron: '0 */2 * * *' # Every 2 hours for testing (more reasonable for testing)
6+
workflow_dispatch: # Manual triggering for development
77
inputs:
88
strategy:
99
description: Update strategy
@@ -18,7 +18,7 @@ on:
1818
dry_run:
1919
description: Dry run (preview only)
2020
required: false
21-
default: false
21+
default: true
2222
type: boolean
2323
packages:
2424
description: Specific packages (comma-separated)
@@ -31,25 +31,31 @@ on:
3131
type: boolean
3232

3333
env:
34+
# For workflow file updates, you need a Personal Access Token with 'repo' and 'workflow' scopes
35+
# Create a PAT at: https://github.com/settings/tokens
36+
# Add it as a repository secret named 'BUDDY_BOT_TOKEN'
37+
# If BUDDY_BOT_TOKEN is not available, falls back to GITHUB_TOKEN (limited permissions)
3438
GITHUB_TOKEN: ${{ secrets.BUDDY_BOT_TOKEN || secrets.GITHUB_TOKEN }}
3539

3640
permissions:
3741
contents: write
3842
pull-requests: write
3943
issues: write
40-
actions: read
44+
actions: write
4145
checks: read
4246
statuses: read
4347

4448
jobs:
45-
dependency-updates:
49+
test-dependency-updates:
4650
runs-on: ubuntu-latest
4751

4852
steps:
4953
- name: Checkout repository
5054
uses: actions/checkout@v4
5155
with:
5256
token: ${{ secrets.BUDDY_BOT_TOKEN || secrets.GITHUB_TOKEN }}
57+
fetch-depth: 0 # Fetch full history for rebasing
58+
persist-credentials: true
5359

5460
- name: Setup Bun
5561
uses: oven-sh/setup-bun@v2
@@ -64,58 +70,136 @@ jobs:
6470
tools: composer
6571
coverage: none
6672

73+
- name: Install dependencies
74+
run: bun install
75+
6776
- name: Install Composer dependencies (if needed)
6877
if: ${{ hashFiles('composer.json') != '' }}
6978
run: composer install --prefer-dist --optimize-autoloader
7079

71-
- name: Install dependencies
72-
run: bun install
73-
7480
- name: Build buddy-bot
7581
run: bun run build
7682

77-
- name: Run dependency updates
83+
- name: Configure Git
84+
run: |
85+
git config --global user.name "buddy-bot[bot]"
86+
git config --global user.email "buddy-bot[bot]@users.noreply.github.com"
87+
88+
- name: Verify Composer setup
89+
run: |
90+
echo "🔍 Verifying Composer and PHP setup..."
91+
php --version
92+
composer --version
93+
echo ""
94+
echo "📦 Checking composer.json..."
95+
if [ -f "composer.json" ]; then
96+
echo "✅ composer.json found"
97+
composer validate --no-check-all --strict
98+
echo ""
99+
echo "📋 Composer packages in composer.json:"
100+
cat composer.json | jq -r '.require, ."require-dev" | to_entries[] | "\(.key): \(.value)"' 2>/dev/null || echo "Unable to parse with jq, showing raw content:"
101+
else
102+
echo "❌ composer.json not found"
103+
fi
104+
105+
- name: Display test configuration
106+
run: |
107+
echo "🧪 **Buddy Bot Testing Mode**"
108+
echo "Strategy: ${{ github.event.inputs.strategy || 'patch' }}"
109+
echo "Dry Run: ${{ github.event.inputs.dry_run || 'true' }}"
110+
echo "Packages: ${{ github.event.inputs.packages || 'all' }}"
111+
echo "Verbose: ${{ github.event.inputs.verbose || 'true' }}"
112+
echo "Triggered by: ${{ github.event_name }}"
113+
echo "Repository: ${{ github.repository }}"
114+
echo "Branch: ${{ github.ref_name }}"
115+
116+
- name: Run Buddy dependency scan
78117
run: |
79118
STRATEGY="${{ github.event.inputs.strategy || 'patch' }}"
80119
PACKAGES="${{ github.event.inputs.packages }}"
81120
VERBOSE="${{ github.event.inputs.verbose || 'true' }}"
82-
DRY_RUN="${{ github.event.inputs.dry_run || 'false' }}"
83121
84122
echo "🔍 Scanning for dependency updates..."
85-
set -e
123+
echo "Strategy: $STRATEGY"
124+
echo "Packages: ${PACKAGES:-all}"
125+
echo "Verbose: $VERBOSE"
126+
echo ""
127+
128+
set -e # Exit on any error
86129
87130
if [ "$PACKAGES" != "" ]; then
88131
if [ "$VERBOSE" = "true" ]; then
89-
bunx buddy-bot scan --packages "$PACKAGES" --verbose
132+
bunx buddy-bot-scan --packages "$PACKAGES" --verbose
90133
else
91-
bunx buddy-bot scan --packages "$PACKAGES"
134+
bunx buddy-bot-scan --packages "$PACKAGES"
92135
fi
93136
else
94137
if [ "$VERBOSE" = "true" ]; then
95-
bunx buddy-bot scan --strategy "$STRATEGY" --verbose
138+
bunx buddy-bot-scan --strategy "$STRATEGY" --verbose
96139
else
97-
bunx buddy-bot scan --strategy "$STRATEGY"
140+
bunx buddy-bot-scan --strategy "$STRATEGY"
98141
fi
99142
fi
100143
101-
if [ "$DRY_RUN" != "true" ]; then
102-
echo "🚀 Running dependency updates..."
103-
if [ "$PACKAGES" != "" ]; then
104-
if [ "$VERBOSE" = "true" ]; then
105-
bunx buddy-bot update --packages "$PACKAGES" --verbose
106-
else
107-
bunx buddy-bot update --packages "$PACKAGES"
108-
fi
144+
env:
145+
GITHUB_TOKEN: ${{ secrets.BUDDY_BOT_TOKEN || secrets.GITHUB_TOKEN }}
146+
147+
- name: Run Buddy dependency updates
148+
if: ${{ github.event.inputs.dry_run != 'true' }}
149+
run: |
150+
STRATEGY="${{ github.event.inputs.strategy || 'patch' }}"
151+
PACKAGES="${{ github.event.inputs.packages }}"
152+
VERBOSE="${{ github.event.inputs.verbose || 'true' }}"
153+
154+
echo "🚀 Running dependency updates..."
155+
echo "This will create/update PRs if outdated dependencies are found"
156+
echo ""
157+
158+
set -e # Exit on any error
159+
160+
if [ "$PACKAGES" != "" ]; then
161+
if [ "$VERBOSE" = "true" ]; then
162+
bunx buddy-bot update --packages "$PACKAGES" --verbose
109163
else
110-
if [ "$VERBOSE" = "true" ]; then
111-
bunx buddy-bot update --strategy "$STRATEGY" --verbose
112-
else
113-
bunx buddy-bot update --strategy "$STRATEGY"
114-
fi
164+
bunx buddy-bot update --packages "$PACKAGES"
115165
fi
116166
else
117-
echo "📋 DRY RUN MODE - No changes made"
167+
if [ "$VERBOSE" = "true" ]; then
168+
bunx buddy-bot update --strategy "$STRATEGY" --verbose
169+
else
170+
bunx buddy-bot update --strategy "$STRATEGY"
171+
fi
118172
fi
119173
120174
env:
121175
GITHUB_TOKEN: ${{ secrets.BUDDY_BOT_TOKEN || secrets.GITHUB_TOKEN }}
176+
177+
- name: Dry run notification
178+
if: ${{ github.event.inputs.dry_run == 'true' }}
179+
run: |
180+
echo "ℹ️ **Dry Run Mode** - No changes were made"
181+
echo "To apply updates, run this workflow again with 'Dry run' set to false"
182+
183+
- name: Create test summary
184+
if: always()
185+
run: |
186+
echo "## 🧪 Buddy Bot Testing Summary" >> $GITHUB_STEP_SUMMARY
187+
echo "" >> $GITHUB_STEP_SUMMARY
188+
echo "- **Strategy**: ${{ github.event.inputs.strategy || 'patch' }}" >> $GITHUB_STEP_SUMMARY
189+
echo "- **Triggered by**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
190+
echo "- **Dry run**: ${{ github.event.inputs.dry_run || 'true' }}" >> $GITHUB_STEP_SUMMARY
191+
echo "- **Packages**: ${{ github.event.inputs.packages || 'all' }}" >> $GITHUB_STEP_SUMMARY
192+
echo "- **Verbose**: ${{ github.event.inputs.verbose || 'true' }}" >> $GITHUB_STEP_SUMMARY
193+
echo "- **Time**: $(date)" >> $GITHUB_STEP_SUMMARY
194+
echo "" >> $GITHUB_STEP_SUMMARY
195+
196+
if [ "${{ github.event_name }}" = "schedule" ]; then
197+
echo "⏰ **Scheduled Run**: This was triggered automatically every 2 hours" >> $GITHUB_STEP_SUMMARY
198+
echo "💡 **Tip**: Use 'Actions' tab to manually trigger with custom settings" >> $GITHUB_STEP_SUMMARY
199+
else
200+
echo "🖱️ **Manual Trigger**: This was triggered manually from the Actions tab" >> $GITHUB_STEP_SUMMARY
201+
echo "⏰ **Auto-Schedule**: This workflow also runs every 2 hours for testing" >> $GITHUB_STEP_SUMMARY
202+
fi
203+
204+
echo "" >> $GITHUB_STEP_SUMMARY
205+
echo "📊 View detailed logs above for scan and update results." >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)