Skip to content

Update flake lock

Update flake lock #66

Workflow file for this run

name: Update flake lock
on:
pull_request:
paths:
- .github/workflows/update.yml
workflow_dispatch:
schedule:
- cron: "0 5 * * 1"
concurrency:
group: parsec-cloud-update
cancel-in-progress: true
jobs:
update:
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
outputs:
commit_sha: ${{ steps.commit.outputs.sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch main branch
run: git fetch origin main
timeout-minutes: 5
- name: Install nix
uses: cachix/install-nix-action@v25
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Config git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Switch to update branch
run: git switch --create update-flake-lock origin/main
- name: Get last stable commit for nixpkgs
id: nixpkgs
run: |
NIXPKGS_CHANNEL=$(jq -r .nodes.nixpkgs.original.ref flake.lock)
STABLE_REVISION=$(curl -L https://channels.nixos.org/$NIXPKGS_CHANNEL/git-revision)
(
echo "chanel=$NIXPKGS_CHANNEL";
echo "revision=$STABLE_REVISION"
) | tee -a $GITHUB_OUTPUT
- name: Update flake lock
run: nix flake update --commit-lock-file --override-input nixpkgs github:nixos/nixpkgs/${{ steps.nixpkgs.outputs.revision }}
timeout-minutes: 5
- name: Get new commit ref
id: commit
run: |
(
echo -n 'sha=';
git rev-parse HEAD
) | tee -a $GITHUB_OUTPUT
- name: Compare changes
id: compare
run: git diff --exit-code origin/main
continue-on-error: true
- name: Create pull request
if: steps.compare.outcome == 'failure' && github.event_name != 'pull_request'
run: |
git push origin update-flake-lock --force
if ! gh pr list --head update-flake-lock | grep -i open; then
echo "No open PR for branch update-flake-lock, creating it..."
gh pr create --fill
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 5
build-on-schedule:
needs: update
if: github.event_name != 'pull_request'
uses: ./.github/workflows/build.yml
with:
git_ref: ${{ needs.update.outputs.commit_sha || github.sha }}