Skip to content

Commit 7dc6741

Browse files
committed
ci/update: cancel scheduled runs that don't bump nixpkgs
This should help mitigate spammy force-pushes that don't actually update the nixpkgs input. This only affects _scheduled_ runs. Manually triggered updates will always force-push to the update branch.
1 parent a2a4bef commit 7dc6741

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/update.yml

+35
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,41 @@ jobs:
6262
echo "EOF" >> "$GITHUB_OUTPUT"
6363
fi
6464
65+
- name: Check if nixpkgs input was changed
66+
if: github.event_name == 'schedule'
67+
env:
68+
repo: ${{ github.repository }}
69+
branch: update/${{ github.ref_name }}
70+
run: |
71+
getAttr() {
72+
nix eval --raw --impure \
73+
--expr '{ ref }: builtins.getFlake ref' \
74+
--argstr ref "$1" "$2"
75+
}
76+
getNixpkgsRev() {
77+
getAttr "$1" 'inputs.nixpkgs.rev'
78+
}
79+
old=$(
80+
getNixpkgsRev "github:$repo/$branch" \
81+
|| echo "" # Could fail, e.g. if the branch is deleted
82+
)
83+
new=$(getNixpkgsRev '.')
84+
if [[ "$old" = "$new" ]]; then
85+
(
86+
echo "nixpkgs rev has not changed ($new). Stopping..."
87+
echo 'You can re-run the workflow manually to update anyway.'
88+
) >&2
89+
(
90+
echo '## Update cancelled'
91+
echo
92+
echo 'The `nixpkgs` rev has not changed (`'"$new"'`).'
93+
echo
94+
echo 'You can re-run the workflow manually to update anyway.'
95+
echo
96+
) >> $GITHUB_STEP_SUMMARY
97+
exit 1
98+
fi
99+
65100
- name: Update generated files
66101
id: generate
67102
if: inputs.generate || github.event_name == 'schedule'

0 commit comments

Comments
 (0)