Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions .github/workflows/flake-lock-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,31 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout repo
- id: gate
name: Gate to first Sunday of the month
run: |-
if [ "$GITHUB_EVENT_NAME" != schedule ] || [ "$(date -u +%u)" = 7 ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "run=false" >> "$GITHUB_OUTPUT"
fi
- if: steps.gate.outputs.run == 'true'
name: Checkout repo
uses: actions/checkout@main
with:
fetch-depth: 1
persist-credentials: false
- name: Install Nix
- if: steps.gate.outputs.run == 'true'
name: Install Nix
uses: nixbuild/nix-quick-install-action@master
- name: Magic Nix Cache(Use GitHub Actions Cache)
- if: steps.gate.outputs.run == 'true'
name: Magic Nix Cache(Use GitHub Actions Cache)
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Update flake.lock
- if: steps.gate.outputs.run == 'true'
name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@main
timeout-minutes: 30
'on':
schedule:
- cron: 0 0 1-7 * 0
- cron: 0 0 1-7 * *
workflow_dispatch: {}
35 changes: 26 additions & 9 deletions flake/actions/flake-lock-update.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
{
lib,
common-permissions,
common-actions,
...
}: {
}: let
# Cron ORs day-of-month and day-of-week when both are set, so "first Sunday"
# can't be expressed directly: fire on days 1-7 and let this gate pick Sunday.
gate = {
name = "Gate to first Sunday of the month";
id = "gate";
run = ''
if [ "$GITHUB_EVENT_NAME" != schedule ] || [ "$(date -u +%u)" = 7 ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "run=false" >> "$GITHUB_OUTPUT"
fi
'';
};
gated = step: step // {"if" = "steps.gate.outputs.run == 'true'";};
in {
flake.actions-nix.workflows.".github/workflows/flake-lock-update.yml" = {
on = {
workflow_dispatch = {};
schedule = [
{
cron = "0 0 1-7 * 0"; # First Sunday of every month at midnight
cron = "0 0 1-7 * *"; # Days 1-7; the gate step keeps only Sunday
}
];
};
Expand All @@ -20,13 +36,14 @@
pull-requests = "write";
};
steps =
common-actions
++ [
{
name = "Update flake.lock";
uses = "DeterminateSystems/update-flake-lock@main";
}
];
[gate]
++ lib.map gated (common-actions
++ [
{
name = "Update flake.lock";
uses = "DeterminateSystems/update-flake-lock@main";
}
]);
};
};
}
Loading