-
Notifications
You must be signed in to change notification settings - Fork 4
55 lines (49 loc) · 1.52 KB
/
nix.yml
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
name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
jobs:
build:
runs-on: x86_64-linux
outputs:
docker-image-name: ${{ steps.docker.outputs.image_name }}
steps:
- uses: actions/checkout@v4
- uses: cachix/cachix-action@v15
with:
name: nammayatri
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Build all flake outputs
run: om ci
- name: Docker tasks
id: docker
if: github.ref == 'refs/heads/main'
run: |
nix build .#dockerImage -o docker-image.tgz
echo "image_name=$(nix eval --raw .#dockerImage.imageName):$(nix eval --raw .#dockerImage.imageTag)" >> $GITHUB_OUTPUT
- name: Upload Docker image tarball
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: docker-image
path: docker-image.tgz
push-docker:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Download Docker image tarball
uses: actions/download-artifact@v4
with:
name: docker-image
- name: Load and push Docker image
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "$GITHUB_TOKEN" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
docker load < docker-image.tgz
docker push ${{ needs.build.outputs.docker-image-name }}
docker logout ghcr.io