Skip to content

Commit 43de9f0

Browse files
committed
feat(ops): update ci
1 parent 1e29fae commit 43de9f0

2 files changed

Lines changed: 80 additions & 38 deletions

File tree

.github/workflows/docker.yml

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

.github/workflows/on_push.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
34+
- name: Format go code
35+
run: |
36+
nix develop -c go fmt
37+
38+
- name: Build app
39+
run: nix build
40+
41+
- name: Check for modified files
42+
run: |
43+
if [[ -n $(git status --porcelain) ]]; then
44+
echo "yarn install produces an impure tree. Please run 'yarn install' and commit the changes."
45+
git status
46+
exit 1
47+
fi
48+
49+
docker:
50+
needs: [checks]
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
56+
57+
- name: Setup Nix
58+
uses: cachix/install-nix-action@v31
59+
60+
- name: Restore and save Nix store
61+
uses: nix-community/cache-nix-action@v6
62+
with:
63+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
64+
65+
- name: Build Docker image
66+
run: nix build .#docker
67+
68+
- name: Login to GitHub Container Registry
69+
uses: docker/login-action@v3
70+
with:
71+
registry: ${{ env.REGISTRY }}
72+
username: ${{ github.actor }}
73+
password: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Push Docker image to GitHub Container Registry
76+
id: push
77+
run: |
78+
docker load < result
79+
docker tag drawbu.dev ${{ env.IMAGE_NAME }}
80+
docker push ${{ env.IMAGE_NAME }}

0 commit comments

Comments
 (0)