forked from benjojo/alertmanager-discord
-
Notifications
You must be signed in to change notification settings - Fork 0
253 lines (205 loc) Β· 8.92 KB
/
Copy pathupdate-dependencies.yml
File metadata and controls
253 lines (205 loc) Β· 8.92 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
---
name: Update Dependencies
on:
schedule:
# Run every Monday at 9:00 AM UTC (1:00 AM PST / 2:00 AM PDT)
- cron: "0 9 * * 1"
workflow_dispatch:
inputs:
update_go_version:
description: "Update Go version"
required: false
type: boolean
default: false
go_version:
description: "Go version (if updating)"
required: false
type: string
default: "1.20"
major_upgrades:
description: "Include major version upgrades"
required: false
type: boolean
default: false
env:
CI: true
GO_VERSION: '1.20'
permissions:
contents: write
pull-requests: write
jobs:
update-dependencies:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: β±οΈ Start timer
id: timer
run: echo "start_time=$(date +%s)" >> "$GITHUB_OUTPUT"
- name: π·οΈ Set lowercase image name
id: image
run: |
echo "IMAGE_NAME=$(echo "${{ github.repository }}" | tr "[:upper:]" "[:lower:]")" >> "$GITHUB_ENV"
- name: π Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: π§ Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ github.event.inputs.update_go_version == 'true' && github.event.inputs.go_version || env.GO_VERSION }}
cache: true
- name: π§ Configure git
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: π Run update-project.sh
id: analyze
env:
MAJOR_UPGRADES: ${{ github.event.inputs.major_upgrades }}
UPDATE_GO_VERSION: ${{ github.event.inputs.update_go_version }}
NEW_GO_VERSION: ${{ github.event.inputs.go_version }}
run: |
ARGS=(--ci)
if [[ "$MAJOR_UPGRADES" == "true" ]]; then
ARGS+=(--major)
fi
if [[ "$UPDATE_GO_VERSION" == "true" ]]; then
ARGS+=(--go-version "$NEW_GO_VERSION")
fi
./scripts/update-project.sh "${ARGS[@]}"
- name: π Show change summary
if: steps.analyze.outputs.no_changes != 'true'
run: |
if [[ -f change-summary.md ]]; then
cat change-summary.md
fi
- name: π Generate PR title
if: steps.analyze.outputs.no_changes != 'true'
id: pr-title
env:
UPDATE_GO_VERSION: ${{ github.event.inputs.update_go_version }}
NEW_GO_VERSION: ${{ github.event.inputs.go_version }}
CHANGES: ${{ steps.analyze.outputs.direct_changes }}
run: |
PR_TITLE="chore(deps): update Go dependencies"
if [[ "$UPDATE_GO_VERSION" == "true" ]]; then
# Validate format before embedding in title
if [[ "$NEW_GO_VERSION" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
PR_TITLE="$PR_TITLE (Go $NEW_GO_VERSION)"
fi
fi
if [[ -n "$CHANGES" ]] && [[ "$CHANGES" =~ ^[0-9]+$ ]] && [[ "$CHANGES" -gt 0 ]]; then
PR_TITLE="$PR_TITLE ($CHANGES packages)"
fi
echo "title=$PR_TITLE" >> "$GITHUB_OUTPUT"
- name: π Create Pull Request
if: steps.analyze.outputs.no_changes != 'true'
id: create-pr
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: automation/update-dependencies
delete-branch: true
title: ${{ steps.pr-title.outputs.title }}
body: |
## π€ Automated Dependency Update
This PR was automatically generated by the weekly dependency update workflow.
### π Update Summary
**Dependency Statistics:**
- Total dependencies before: ${{ steps.analyze.outputs.current_deps }}
- Total dependencies after: ${{ steps.analyze.outputs.new_deps }}
- Direct dependency changes: ${{ steps.analyze.outputs.direct_changes }}
**Go Version:**
- Current: ${{ steps.analyze.outputs.current_go_version }}
${{ github.event.inputs.update_go_version == 'true' && format('- Updated to: go{0}', github.event.inputs.go_version) || '- No version update' }}
### π Changes Made
- β
Updated Go dependencies to latest compatible versions
- π All security patches applied
- π§ͺ Tests passed with updated dependencies
- π Dependencies verified with `go mod verify`
### π Manual Verification Required
Before merging, please:
1. **Review dependency changes**: Check the Files tab for `go.mod` and `go.sum` changes
2. **Check CI status**: Ensure all checks pass (quality, tests, build)
3. **Test locally** (optional):
```bash
git checkout automation/update-dependencies
go mod download
go test -v ./...
go build -o alertmanager-discord
```
4. **Check for breaking changes**: Review changelogs of major updates
5. **Test Docker build**:
```bash
docker build -t alertmanager-discord:test .
docker run --rm alertmanager-discord:test -healthcheck
```
### π‘οΈ Security Check
Run security audit locally:
```bash
go list -json -m all
# Review for known vulnerabilities
```
### π Notes
- **Triggered by**: ${{ github.event_name }}
- **Major upgrades**: ${{ github.event.inputs.major_upgrades || 'false' }}
- **Go version update**: ${{ github.event.inputs.update_go_version || 'false' }}
- **Update strategy**: ${{ github.event.inputs.major_upgrades == 'true' && 'All versions (including major)' || 'Patch and minor versions only' }}
---
<details>
<summary>π Detailed Changes</summary>
$(cat change-summary.md)
</details>
<details>
<summary>π¦ Dependencies Before Update</summary>
```
$(cat deps-before.txt)
```
</details>
<details>
<summary>π¦ Dependencies After Update</summary>
```
$(cat deps-after.txt)
```
</details>
commit-message: |
chore(deps): update Go dependencies
- Update Go packages to latest compatible versions
- Run go mod tidy to clean up module files
- Verify all dependencies
${{ github.event.inputs.update_go_version == 'true' && format('- Update Go version to {0}', github.event.inputs.go_version) || '' }}
Generated by automated dependency update workflow
Update strategy: ${{ github.event.inputs.major_upgrades == 'true' && 'major+minor+patch' || 'minor+patch only' }}
assignees: SimplicityGuy
labels: dependencies,automated
- name: π Collect metrics
if: always()
id: metrics
run: |
end_time=$(date +%s)
duration=$((end_time - ${{ steps.timer.outputs.start_time }}))
echo "duration=${duration}" >> "$GITHUB_OUTPUT"
CHANGES="${{ steps.analyze.outputs.no_changes == 'true' && 'none' || steps.analyze.outputs.direct_changes }}"
echo "::notice title=Dependency Update Metrics::Duration: ${duration}s, Changes: ${CHANGES}"
- name: π Summary
if: always()
run: |
echo "βββββββββββββββββββββββββββββββββββββββ"
echo " Dependency Update Summary"
echo "βββββββββββββββββββββββββββββββββββββββ"
if [[ "${{ steps.analyze.outputs.no_changes }}" == "true" ]]; then
echo "β
All dependencies are already up to date!"
echo " No changes detected in go.mod or go.sum"
elif [[ "${{ steps.create-pr.conclusion }}" == "success" ]]; then
echo "β
Successfully created PR with dependency updates"
echo "π Review the PR: ${{ steps.create-pr.outputs.pull-request-url }}"
echo "π Direct changes: ${{ steps.analyze.outputs.direct_changes }}"
echo "β±οΈ Duration: ${{ steps.metrics.outputs.duration }}s"
else
echo "β Failed to update dependencies or create PR"
if [[ -f change-summary.md ]]; then
cat change-summary.md
fi
fi
echo "βββββββββββββββββββββββββββββββββββββββ"