-
-
Notifications
You must be signed in to change notification settings - Fork 6
144 lines (142 loc) · 5.93 KB
/
Copy pathbuild-push-latest.yaml
File metadata and controls
144 lines (142 loc) · 5.93 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: latest-build
on:
workflow_dispatch:
pull_request:
paths:
- Dockerfile
- flake.lock
- .github/workflows/build-push-latest.yaml
branches:
- develop
- main
push:
paths:
- Dockerfile
- flake.lock
- .github/workflows/build-push-latest.yaml
tags:
- v*
branches:
- develop
- main
jobs:
docker-build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nix_channel:
- nixos_channel: "nixos-unstable"
home_manager_version_string: "master"
main_nix_channel: "https://nixos.org/channels/nixos-unstable"
home_manager_channel: "https://github.com/nix-community/home-manager/archive/master.tar.gz"
default_tag: false
- nixos_channel: "nixos-25.11"
home_manager_version_string: "release-25.11"
main_nix_channel: "https://nixos.org/channels/nixos-25.11"
home_manager_channel: "https://github.com/nix-community/home-manager/archive/release-25.11.tar.gz"
default_tag: true
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: cachix/install-nix-action@51f3067b56fe8ae331890c77d4e454f6d60615ff # v31
with:
nix_path: nixpkgs=channel:${{matrix.nix_channel.nixos_channel}}
extra_nix_config: |
filter-syscalls = false
experimental-features = nix-command flakes
extra-platforms = aarch64-linux
- uses: DeterminateSystems/flakehub-cache-action@main
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/lucernae/devcontainer-nix
flavor: |
latest=false
prefix=${{matrix.nix_channel.nixos_channel}}---
tags: |
type=raw,value=stable,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
type=raw,value=stable${{ matrix.nix_channel.default_tag && ',prefix=' || '' }},enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=latest${{ matrix.nix_channel.default_tag && ',prefix=' || '' }},enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}.{{minor}}.{{patch}}
type=semver${{ matrix.nix_channel.default_tag && ',prefix=' || '' }},pattern=v{{version}}
type=semver${{ matrix.nix_channel.default_tag && ',prefix=' || '' }},pattern=v{{major}}
type=semver${{ matrix.nix_channel.default_tag && ',prefix=' || '' }},pattern=v{{major}}.{{minor}}
type=semver${{ matrix.nix_channel.default_tag && ',prefix=' || '' }},pattern=v{{major}}.{{minor}}.{{patch}}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event.pull_request.base.repo.url == github.event.pull_request.head.repo.url }}
build-args: |
NIXOS_VERSION=${{matrix.nix_channel.nixos_channel}}
MAIN_NIX_CHANNEL=${{matrix.nix_channel.main_nix_channel}}
HOME_MANAGER_CHANNEL=${{matrix.nix_channel.home_manager_channel}}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: |
type=gha,scope=test
type=gha,scope=prod
cache-to: type=gha,scope=prod
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
# Commented out. Possibly useful in the future.
# smoke-test:
# runs-on: ubuntu-latest
# needs:
# - docker-build
# strategy:
# fail-fast: false
# matrix:
# docker_platform:
# - linux/amd64
# - linux/arm64
# nix_channel:
# - nixos_channel: "nixos-unstable"
# home_manager_version_string: "master"
# main_nix_channel: "https://nixos.org/channels/nixos-unstable"
# home_manager_channel: "https://github.com/nix-community/home-manager/archive/master.tar.gz"
# - nixos_channel: "nixos-25.05"
# home_manager_version_string: "release-25.05"
# main_nix_channel: "https://nixos.org/channels/nixos-25.05"
# home_manager_channel: "https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz"
# steps:
# - uses: actions/checkout@v3
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - uses: cachix/install-nix-action@v22
# with:
# nix_path: nixpkgs=channel:${{matrix.nix_channel.nixos_channel}}
# extra_nix_config: |
# filter-syscalls = false
# experimental-features = nix-command flakes
# extra-platforms = aarch64-linux
# - uses: DeterminateSystems/flakehub-cache-action@main
# - name: Run smoke test
# run: |
# cat << EOF | docker run --rm --platform ${{matrix.docker_platform}} -i ${{needs.docker-build.outputs.docker_output_tags}} bash
# node --version
# nix-shell -p coreutils --run 'uname -a'
# nix-shell -p jq --run "nix eval --impure --expr 'builtins.currentSystem' | jq -r '.'"
# EOF