Automatic Nix Flake Lock Update #260
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024 3WEBS LLC | |
# SPDX-License-Identifier: GPL-3.0-or-later | |
name: Automatic Nix Flake Lock Update | |
on: # yamllint disable-line | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
jobs: | |
update: | |
name: π Automatic Nix Flake Lock Update | |
runs-on: ubuntu-latest | |
steps: | |
- name: π¦ Checkout Repository | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
fetch-depth: 2 | |
- name: π§ Configure Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git branch update-flake-lock | |
git switch update-flake-lock | |
- name: βοΈ Install Nix | |
uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b # v27 | |
with: | |
extra_nix_config: "system-features = nixos-test benchmark big-parallel kvm" | |
- name: βοΈ Cache Nix Store | |
uses: DeterminateSystems/magic-nix-cache-action@b46e247b898aa56e6d2d2e728dc6df6c84fdb738 # v7 | |
with: | |
# Skip uploads to save time | |
use-gha-cache: false | |
use-flakehub: false | |
# Disable telemetry | |
diagnostic-endpoint: "" | |
- name: π Update Flake | |
run: nix flake update | |
- name: πΎ Commit Changes | |
run: | | |
git add flake.lock | |
git commit -m "Automatic Nix Flake Lock Update" | |
- name: π€ Force-Push Changes | |
run: git push --force --set-upstream origin update-flake-lock | |
- name: π Check for Existing PR | |
id: check_pr | |
run: | | |
PR_URL=$(gh pr list --base main --head update-flake-lock --json url --jq '.[0].url') | |
echo "::set-output name=pr_url::$PR_URL" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: π€ Open PR | |
if: steps.check_pr.outputs.pr_url == '' | |
run: gh pr create --base main --head update-flake-lock --title "Automatic Nix Flake Lock Update" --body "" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |