summaryrefslogtreecommitdiff
path: root/.github/workflows/update-lock.yaml
blob: e6db6958a57f85395526d9478aefc422c4b6239f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Update flake.lock

on:
  workflow_call:
    inputs:
      commit-message:
        description: "Summary for lockfile commit"
        required: true
        type: string
      flake-inputs:
        description: "Flake inputs to update"
        required: false
        default: ""
        type: string
    secrets:
      PRIVATE_KEY:
        description: GitHub Bot Application client secret
        required: true

jobs:
  update:
    name: Update & make PR

    runs-on: ubuntu-latest

    steps:
      - name: Generate GitHub App token
        uses: actions/create-github-app-token@v1
        id: app-token
        with:
          app-id: ${{ vars.APP_ID }}
          private-key: ${{ secrets.PRIVATE_KEY }}

      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          token: ${{ steps.app-token.outputs.token }}

      - name: Install Nix
        uses: cachix/install-nix-action@v31

      - name: Update flake.lock
        run: |
          nix flake update ${{ inputs.flake-inputs }}

      - name: Create Pull request
        id: pull-request
        uses: peter-evans/create-pull-request@v7
        with:
          branch: update-flake-lock
          commit-message: ${{ inputs.commit-message }}
          title: ${{ inputs.commit-message }}
          token: ${{ steps.app-token.outputs.token }}
          sign-commits: true

      - name: Enable auto-merge
        shell: bash
        if: ${{ env.PR_ID != '' }}
        run: gh pr merge --auto --rebase "$PR_ID"
        env:
          PR_ID: ${{ steps.pull-request.outputs.pull-request-number }}
          GH_TOKEN: ${{ steps.app-token.outputs.token }}