From 9f8459a7d397de73c0ac8e2dfd1f5565773eb160 Mon Sep 17 00:00:00 2001 From: Patrick Stevens <3138005+Smaug123@users.noreply.github.com> Date: Fri, 12 Jul 2024 12:12:44 +0100 Subject: [PATCH] Add flake update workflow (#183) --- .github/workflows/flake_update.yaml | 56 +++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/flake_update.yaml diff --git a/.github/workflows/flake_update.yaml b/.github/workflows/flake_update.yaml new file mode 100644 index 0000000..b7cf4c4 --- /dev/null +++ b/.github/workflows/flake_update.yaml @@ -0,0 +1,56 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json +name: Weekly Nix Flake Update + +on: + schedule: + - cron: '0 0 * * 0' # Runs at 00:00 every Sunday + workflow_dispatch: # Allows manual triggering + +jobs: + update-nix-flake: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@V27 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + + - name: Update Nix flake + run: 'nix flake update' + + - name: Build passthru + run: 'nix build .#default.passthru.fetch-deps' + + - name: Run passthru + run: 'cp "$(./result | grep "Successfully wrote " | cut -d / -f 2-)" nix/deps.nix' + + - name: Format + run: 'nix develop .#ci --command alejandra .' + + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v6.1.0 + with: + commit-message: Update Nix flake + title: Weekly Nix flake update + body: | + This is an automated pull request to update the Nix flake. + + Changes: + ``` + ${{ steps.create-diff.outputs.diff }} + ``` + branch: nix-flake-update + delete-branch: true + + - name: Enable Pull Request Automerge + if: steps.cpr.outputs.pull-request-operation == 'created' + uses: peter-evans/enable-pull-request-automerge@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + merge-method: squash