Skip to content

Commit 35a6641

Browse files
authored
ci: add workflows for automatic updates and checks (#9)
* ci: add workflows for automatic updates and checks * ci: add repository-dispatch trigger and usage examples
1 parent 73b3a9f commit 35a6641

5 files changed

Lines changed: 129 additions & 1 deletion

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: check-flake-packages
2+
on:
3+
pull_request:
4+
paths-ignore:
5+
- '.github/**'
6+
- 'maintainers/**'
7+
- 'examples/**'
8+
- '.gitignore'
9+
- '**/README.md'
10+
11+
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v6
17+
- name: Install nix
18+
uses: cachix/install-nix-action@v31
19+
with:
20+
nix_path: nixpkgs=channel:nixos-unstable
21+
extra_nix_config: |
22+
experimental-features = nix-command flakes
23+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
24+
- name: Check evaluation
25+
run: nix flake check
26+
- name: Build nix packages
27+
run: nix build --no-link --print-build-logs .#pico-fido
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: update-flake-lock
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 2 * * 0'
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
lockfile:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v6
17+
- name: Install nix
18+
uses: cachix/install-nix-action@v31
19+
with:
20+
nix_path: nixpkgs=channel:nixos-unstable
21+
extra_nix_config: |
22+
experimental-features = nix-command flakes
23+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
24+
- name: Update flake.lock
25+
id: update
26+
uses: DeterminateSystems/update-flake-lock@v28
27+
with:
28+
token: ${{ secrets.WORKFLOW_PR_TOKEN }}
29+
pr-body: |
30+
Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action.
31+
32+
```
33+
{{ env.GIT_COMMIT_MESSAGE }}
34+
```
35+
pr-labels: "automated"
36+
- name: Print PR number
37+
run: echo Pull request number is ${{ steps.update.outputs.pull-request-number }}.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: update-flake-packages
2+
on:
3+
workflow_dispatch:
4+
repository_dispatch:
5+
types: [update-flake-packages]
6+
schedule:
7+
- cron: '0 4 * * 0'
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
packages:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v6
19+
- name: Install nix
20+
uses: cachix/install-nix-action@v31
21+
with:
22+
nix_path: nixpkgs=channel:nixos-unstable
23+
extra_nix_config: |
24+
experimental-features = nix-command flakes
25+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
26+
- name: Copy nixpkgs scripts
27+
run: |
28+
NIXPKGS=$(nix-instantiate --eval -E '<nixpkgs>')
29+
cp -r $NIXPKGS/maintainers .
30+
chmod -R +w .
31+
sed -i "s|./../../default.nix|$NIXPKGS|g" maintainers/scripts/update.nix
32+
- name: Update flake packages
33+
id: update
34+
uses: gepbird/nix-update-action@v2.1.1
35+
with:
36+
token: ${{ secrets.WORKFLOW_PR_TOKEN }}
37+
# Ensure all *-firmwares are on the blacklist.
38+
blacklist: "default,pico-fido-firmwares"
39+
pr-body: |
40+
Automated changes by the [nix-update-actions](https://github.com/gepbird/nix-update-action) GitHub Action.
41+
pr-labels: "automated"
42+
- name: Print PR number
43+
run: echo Pull request number is ${{ steps.update.outputs.pull-request-number }}.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
result
2-
result-*
2+
result-*
3+
maintainers/

examples/repository-dispatch.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: repository-dispatch
2+
on:
3+
workflow_dispatch:
4+
push:
5+
tags:
6+
- v**
7+
8+
jobs:
9+
repository-dispatch:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Repository Dispatch
13+
uses: peter-evans/repository-dispatch@v4.0.1
14+
with:
15+
# You can also use a fine-grained personal access token (beta). It needs the following permissions on the target repositories:
16+
# contents: read & write
17+
# metadata: read only (automatically selected when selecting the contents permission)
18+
token: ${{ secrets.PAT }}
19+
repository: librekeys/pico-fido-firmwares
20+
event-type: update-flake-packages

0 commit comments

Comments
 (0)