Skip to content

Commit 0d9fbd9

Browse files
committed
feat(ops): update ci
1 parent 68be5e4 commit 0d9fbd9

File tree

2 files changed

+81
-38
lines changed

2 files changed

+81
-38
lines changed

.github/workflows/docker.yml

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

.github/workflows/on_push.yml

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

0 commit comments

Comments
 (0)