-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (129 loc) · 4.9 KB
/
scan-updates.yml
File metadata and controls
154 lines (129 loc) · 4.9 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: 🔍 Scan Updates
on:
schedule:
- cron: '0 8 * * *' # Every day at 8:00 UTC
workflow_dispatch:
permissions:
contents: write
pull-requests: write
concurrency:
group: scan-updates
cancel-in-progress: false
jobs:
detect-updates:
name: 🔍 Detect Available Updates
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
updates: ${{ steps.watcher.outputs.updates }}
has_updates: ${{ steps.watcher.outputs.has_updates }}
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'requirements/base.txt'
- name: Install dependencies
run: pip install -r requirements/base.txt
- name: 🔍 Scan for Updates
id: watcher
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYTHONPATH: ${{ github.workspace }}
run: |
echo "::group::🔍 Checking for upstream updates"
# Run watcher without --update to just detect
output=$(python3 -m core.engine.watcher 2>&1)
echo "$output"
# Parse output to extract updates (handle multi-line format)
updates=$(echo "$output" | awk '
/Checking [^ ]+ \(/ {
match($0, /Checking ([^ ]+) /, arr);
exporter = arr[1];
}
/New version available:/ {
match($0, /New version available: ([^ ]+)/, arr);
version = arr[1];
printf "{\"name\":\"%s\",\"version\":\"%s\"}\n", exporter, version;
}
' | jq -s '.')
if [ "$(echo "$updates" | jq 'length')" -gt 0 ]; then
echo "has_updates=true" >> $GITHUB_OUTPUT
# Compact JSON to single line for GitHub Actions output
echo "updates=$(echo "$updates" | jq -c '.')" >> $GITHUB_OUTPUT
echo ""
echo "📦 Updates detected:"
echo "$updates" | jq -r '.[] | " - \(.name): \(.version)"'
else
echo "has_updates=false" >> $GITHUB_OUTPUT
echo "updates=[]" >> $GITHUB_OUTPUT
echo "✓ All exporters are up to date"
fi
echo "::endgroup::"
create-prs:
name: 📝 Create PR for ${{ matrix.exporter.name }}
needs: detect-updates
if: needs.detect-updates.outputs.has_updates == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
max-parallel: 1
matrix:
exporter: ${{ fromJson(needs.detect-updates.outputs.updates) }}
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
- name: 📝 Update Manifest for ${{ matrix.exporter.name }}
env:
EXPORTER_NAME: ${{ matrix.exporter.name }}
NEW_VERSION: ${{ matrix.exporter.version }}
run: |
echo "::group::📝 Updating $EXPORTER_NAME to $NEW_VERSION"
manifest="exporters/$EXPORTER_NAME/manifest.yaml"
if [ ! -f "$manifest" ]; then
echo "Error: Manifest not found: $manifest"
exit 1
fi
# Update version in manifest using sed
sed -i "s/^version:.*/version: \"$NEW_VERSION\"/" "$manifest"
echo "✓ Updated $manifest"
cat "$manifest" | grep "^version:"
echo "::endgroup::"
- name: 📤 Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GH_PAT }}
commit-message: "chore(deps): update ${{ matrix.exporter.name }} to ${{ matrix.exporter.version }}"
title: "chore(deps): update ${{ matrix.exporter.name }} to ${{ matrix.exporter.version }}"
body: |
## 🔄 Automated Version Update
**Exporter:** `${{ matrix.exporter.name }}`
**New Version:** `${{ matrix.exporter.version }}`
This PR was automatically created by the version watcher.
### Changes
- Update `${{ matrix.exporter.name }}` manifest version
### Validation
- [ ] CI checks pass
- [ ] Build succeeds for all targets
- [ ] Packages published successfully
---
🤖 *Automated by version watcher - will auto-merge if checks pass*
branch: auto/update-${{ matrix.exporter.name }}
delete-branch: true
labels: |
dependencies
automated
author: SckyzO <683678+SckyzO@users.noreply.github.com>
- name: ✅ Enable Auto-merge
if: steps.cpr.outputs.pull-request-operation == 'created'
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Enabling auto-merge for PR #$PR_NUMBER"
gh pr merge "$PR_NUMBER" --auto --squash --repo ${{ github.repository }}