/ piped-nix / .github / workflows / update.yml
update.yml
 1  name: update
 2  
 3  on:
 4    schedule:
 5      - cron: "0 0 * * *"
 6    workflow_dispatch:
 7  
 8  permissions:
 9    contents: write
10  
11  jobs:
12    update:
13      name: update
14      runs-on: ubuntu-latest
15      steps:
16        - uses: actions/checkout@v4
17        - name: Install Nix
18          uses: DeterminateSystems/nix-installer-action@v9
19        - name: Configure git
20          run: |
21            git config --global user.email "github-actions[bot]@users.noreply.github.com"
22            git config --global user.name "github-actions[bot]"
23        - name: Update flake.lock
24          id: update
25          run: |
26            nix flake update --commit-lock-file
27            if [[ "$(git rev-parse origin/main)" != "$(git rev-parse main)" ]]; then
28              updated=1
29            else
30              updated=0
31            fi
32            echo "updated=$updated" >> "$GITHUB_OUTPUT"
33        - name: Lock backend
34          if: steps.update.outputs.updated == '1'
35          run: |
36            env -i $(which nix) run .#lockBackend
37            git add backend-gradle.lock
38            git commit --amend --no-edit
39        - name: Push
40          if: steps.update.outputs.updated == '1'
41          run: git push