Setup CI task to auto update flake.lock

This commit is contained in:
Lan Tian 2025-12-08 20:36:34 -08:00
parent 28369594a1
commit 96b4b59a9b
No known key found for this signature in database
GPG Key ID: 04E66B6B25A0862B

View File

@ -1,24 +1,78 @@
name: 'Flake.lock: update Nix dependencies' name: 'Auto update packages'
on: on:
workflow_dispatch: # allows manual triggering workflow_dispatch:
schedule: schedule:
- cron: '37 17 * * 5' # runs weekly on Friday at 17:37 - cron: '37 17 * * *'
jobs: jobs:
nix-flake-update: auto-update:
permissions:
contents: write
id-token: write
issues: write
pull-requests: write
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
GIT_SSL_NO_VERIFY: 'true'
steps: steps:
- uses: actions/checkout@v4 - name: Maximize build space
- uses: DeterminateSystems/determinate-nix-action@v3 uses: easimon/maximize-build-space@master
- uses: DeterminateSystems/update-flake-lock@main
with: with:
pr-title: 'Update Nix flake inputs' # Title of PR to be created root-reserve-mb: 8192
pr-labels: | # Labels to be set on the PR temp-reserve-mb: 1024
dependencies swap-size-mb: 4096
automated build-mount-path: '/nix'
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Install nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes ca-derivations
extra-experimental-features = nix-command flakes ca-derivations
access-tokens = github.com=${{ secrets.AUTOMERGE_TOKEN }}
extra-platforms = i686-linux aarch64-linux arm-linux
log-lines = 25
- name: Set nix daemon tmpdir path
run: |
sudo mkdir -p /nix/tmpdir
sudo chown "$(whoami)" /nix/tmpdir
cat > override.conf <<EOF
[Service]
Environment="TMPDIR=/nix/tmpdir"
EOF
sudo mkdir /etc/systemd/system/nix-daemon.service.d/
sudo mv override.conf /etc/systemd/system/nix-daemon.service.d/override.conf
sudo systemctl daemon-reload
sudo systemctl restart nix-daemon
- name: Build nix packages
run: |
export TMPDIR=/nix/tmpdir
nix flake update
- env:
API_TOKEN_GITHUB: ${{ secrets.AUTOMERGE_TOKEN }}
run: |
# https://github.com/cpina/github-action-push-to-another-repository/issues/75
git config --unset-all http.https://github.com/.extraheader || true
git config --global user.email "xddxdd-bot@users.noreply.github.com"
git config --global user.name "xddxdd-bot"
git add .
if git commit -m "auto: update packages" ; then
git remote remove origin
git remote add origin "https://xddxdd-bot:$API_TOKEN_GITHUB@github.com/xddxdd/nur-packages.git"
git push -u origin master
fi