Repository navigation
124 lines (111 loc) · 4.43 KB
/
Copy pathupdate-packages.yml
File metadata and controls
124 lines (111 loc) · 4.43 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
name: Update packages
on:
schedule:
# Daily at 06:00 UTC
- cron: '0 6 * * *'
workflow_dispatch:
inputs:
package:
description: 'Package to update (blank = all)'
required: false
type: string
concurrency:
group: update-packages
cancel-in-progress: true
jobs:
update:
# Runs on aarch64-linux to match flake.nix's `systems` (aarch64-linux,
# aarch64-darwin) so nix-update can build arm64 FODs (e.g. vendorHash).
runs-on: ubuntu-24.04-arm
permissions:
contents: read
issues: write
strategy:
fail-fast: false
matrix:
include:
# beads carries Dolt cross-clone schema migrations (see
# migrating-beads-schema); never auto-merge it.
- package: beads
auto_merge: false
steps:
- name: Check filter
if: inputs.package && inputs.package != matrix.package
run: echo "SKIP=true" >> "$GITHUB_ENV"
- name: Checkout repository
id: checkout
if: env.SKIP != 'true'
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Nix
if: env.SKIP != 'true'
uses: DeterminateSystems/nix-installer-action@v14
with:
# Determinate Nix enables lazy-trees by default, which causes
# upstream nix-update's nix-instantiate to fail with ENOENT on
# unmaterialized /nix/store/...-source paths.
extra-conf: |
lazy-trees = false
- name: Run nix-update
if: env.SKIP != 'true'
run: |
nix run --inputs-from . nixpkgs#nix-update -- --flake "${{ matrix.package }}"
- name: Check for changes
if: env.SKIP != 'true'
id: diff
run: |
if git diff --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
version=$(nix eval --raw ".#packages.aarch64-linux.${{ matrix.package }}.version" 2>/dev/null || echo "unknown")
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
fi
- name: Create PR
if: env.SKIP != 'true' && steps.diff.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.UPDATE_TOKEN }}
AUTO_MERGE: ${{ matrix.auto_merge }}
run: |
set -euo pipefail
pkg="${{ matrix.package }}"
version="${{ steps.diff.outputs.version }}"
branch="auto/update-${pkg}"
git checkout -B "$branch"
git add -A
git -c user.name="github-actions[bot]" \
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -m "chore(deps): update ${pkg} to ${version}"
git push -q "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "HEAD:refs/heads/${branch}" --force
# gh pr view matches merged/closed PRs too -- only skip if truly open
pr_state=$(gh pr view "$branch" --json state -q '.state' 2>/dev/null || echo "NONE")
if [ "$pr_state" = "OPEN" ]; then
echo "PR already open for $branch, force-pushed update"
else
{
echo "Automated update of \`${pkg}\` to \`${version}\` via \`nix-update\`."
if [ "$pkg" = "beads" ]; then
echo
echo "**Human-merged (no auto-merge):** upgrading \`bd\` can trigger cross-clone Dolt schema migrations across hosts. Follow the \`migrating-beads-schema\` skill (single-migrator discipline) before merging."
fi
} > /tmp/pr-body.md
gh pr create \
--title "chore(deps): update ${pkg} to ${version}" \
--body-file /tmp/pr-body.md \
--label "dependencies,automated" \
--head "$branch"
if [ "$AUTO_MERGE" = "true" ]; then
pr_number=$(gh pr view "$branch" --json number -q '.number')
gh pr merge "$pr_number" --auto --squash
fi
fi
- name: Report workflow status
if: always() && env.SKIP != 'true' && steps.checkout.outcome == 'success'
env:
GH_TOKEN: ${{ github.token }}
run: |
python3 .github/scripts/report-workflow-failure.py \
--workflow "${{ github.workflow }} (${{ matrix.package }})" \
--status "${{ job.status }}" \
--run-url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"