Skip to content

Commit 4268ffd

Browse files
committed
feat(ops): update ci
1 parent 68be5e4 commit 4268ffd

3 files changed

Lines changed: 76 additions & 39 deletions

File tree

.github/workflows/docker.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/on_push.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Check build and push OCI image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ghcr.io/${{ github.repository }}
11+
12+
jobs:
13+
checks:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Nix
20+
uses: cachix/install-nix-action@v31
21+
22+
- name: Restore and save Nix store
23+
uses: nix-community/cache-nix-action@v6
24+
with:
25+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
26+
27+
- name: Prepare dev shell
28+
run: nix build .#devShells.x86_64-linux.default
29+
30+
- name: Check dependencies
31+
run: |
32+
nix develop -c go mod tidy
33+
nix develop -c go mod vendor
34+
test -z "$(git status --porcelain)" || git status && exit 1
35+
36+
- name: Format go code
37+
run: |
38+
nix develop -c go fmt
39+
test -z "$(git status --porcelain)" || git status && exit 1
40+
41+
- name: Build app
42+
run: nix build
43+
44+
docker:
45+
needs: [checks]
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Setup Nix
53+
uses: cachix/install-nix-action@v31
54+
55+
- name: Restore and save Nix store
56+
uses: nix-community/cache-nix-action@v6
57+
with:
58+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
59+
60+
- name: Build Docker image
61+
run: nix build .#docker
62+
63+
- name: Login to GitHub Container Registry
64+
uses: docker/login-action@v3
65+
with:
66+
registry: ${{ env.REGISTRY }}
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Push Docker image to GitHub Container Registry
71+
id: push
72+
run: |
73+
docker load < result
74+
docker tag drawbu.dev ${{ env.IMAGE_NAME }}
75+
docker push ${{ env.IMAGE_NAME }}

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
devShells.default = pkgs.mkShell {
6969
inputsFrom = builtins.attrValues packages;
70-
packages = [ ];
70+
packages = with pkgs; [ git ];
7171
};
7272

7373
packages = {

0 commit comments

Comments
 (0)