-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (120 loc) · 4.98 KB
/
Copy pathhades-version-drift.yml
File metadata and controls
131 lines (120 loc) · 4.98 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
name: HADES Version Drift
on:
workflow_dispatch:
schedule:
- cron: "17 10 * * 1"
permissions:
contents: write
issues: write
jobs:
check-hades-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Refresh latest HADES target metadata
run: |
scripts/hades/check_hades_versions.py \
--mode latest \
--write-targets \
--report output/hades/latest-target-drift.md \
--json output/hades/latest-target-drift.json \
--no-fail
- name: Validate stable HADES release lock parity
run: |
scripts/hades/check_hades_versions.py \
--mode lock \
--report output/hades/stable-release-lock-parity.md \
--json output/hades/stable-release-lock-parity.json \
--no-fail
- name: Upload HADES drift reports
uses: actions/upload-artifact@v4
with:
name: hades-version-drift
path: output/hades/
# GitHub Actions is not permitted to open PRs under the org policy, so
# instead of peter-evans/create-pull-request we push the refreshed targets
# to a branch and open (or update) a tracking issue. A human opens the PR
# from the branch — or enables "Allow GitHub Actions to create and approve
# pull requests" in repo settings to restore the automated PR.
- name: Detect target drift
id: drift
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No HADES target drift detected."
exit 0
fi
echo "changed=true" >> "$GITHUB_OUTPUT"
{
echo "diffstat<<DIFF_EOF"
git diff --stat
echo "DIFF_EOF"
} >> "$GITHUB_OUTPUT"
- name: Push drift branch
if: steps.drift.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git switch -C automation/hades-version-drift
git add -A
git commit -m "chore(hades): refresh target package versions"
git push --force origin automation/hades-version-drift
- name: Open or update drift issue
if: steps.drift.outputs.changed == 'true'
uses: actions/github-script@v9
env:
DIFFSTAT: ${{ steps.drift.outputs.diffstat }}
with:
script: |
const marker = '<!-- hades-drift-bot -->';
const branch = 'automation/hades-version-drift';
const title = 'chore(hades): target package version drift detected';
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const compareUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/compare/main...${branch}?expand=1`;
const body = [
marker,
'## HADES target package drift detected',
'',
'The weekly HADES version check refreshed the tracked target versions and',
`pushed the proposed change to \`${branch}\`.`,
'',
'```',
(process.env.DIFFSTAT || '').trim() || '(see workflow run artifacts)',
'```',
'',
`**Review & merge:** [open a PR from \`${branch}\`](${compareUrl}).`,
`**Drift reports:** download the \`hades-version-drift\` artifact from ${runUrl}`,
'',
'> GitHub Actions cannot open the PR directly under the current org/repo',
'> policy, so this issue is the notification. Open the PR manually, or enable',
'> "Allow GitHub Actions to create and approve pull requests" in Settings →',
'> Actions → General to restore the fully-automated flow.',
].join('\n');
const open = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100,
});
const existing = open.find((i) => i.body && i.body.includes(marker));
if (existing) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existing.number,
body,
});
core.info(`Updated HADES drift issue #${existing.number}`);
} else {
const created = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body,
labels: ['dependencies'],
});
core.info(`Opened HADES drift issue #${created.data.number}`);
}