-
Notifications
You must be signed in to change notification settings - Fork 5
63 lines (63 loc) · 1.88 KB
/
build.yaml
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
name: Build
on:
pull_request:
workflow_call:
outputs:
image_tag:
description: The tag for the built image
value: ${{ jobs.build.outputs.image_tag }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.build.outputs.image_tag }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- uses: cachix/cachix-action@v12
with:
name: tstr
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Validate generated code is up to date
run: |
nix develop -c dev/up
nix develop -c dev/gen
nix develop -c dev/down
if [ -n "$(git status --porcelain)" ]; then
echo "There is outdated generated code. Please regenerate with `dev/gen`.";
git status
exit 1
fi
- name: Build container image
id: build
run: |
nix build .#image
echo "image_tag=$(nix eval --raw .#image.imageTag)" >> $GITHUB_OUTPUT
- name: Upload built image
uses: actions/upload-artifact@v3
with:
name: image
path: result
push:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
outputs:
image_tag: ${{ steps.push.outputs.image_tag }}
steps:
- name: Download built image
uses: actions/download-artifact@v3
with:
name: image
- name: Load container image
run: "docker load < result"
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: nanzhong
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Push container image
id: push
run: |
docker push "nanzhong/tstr:${{ needs.build.outputs.image_tag }}"
echo "image_tag=${{ needs.build.outputs.image_tag }}" >> $GITHUB_OUTPUT