summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 51f5e9e1d4ca606f97358f3f13bf8e72562598ef (plain)
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
name: ci

on:
  push:
    paths:
      - "**.lock"
      - "**.nix"
      - "**.rs"
      - "**.toml"
  pull_request:
    paths:
      - "**.lock"
      - "**.nix"
      - "**.rs"
      - "**.toml"
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    permissions:
      contents: read
      packages: write

    strategy:
      matrix:
        output: [teawiebot, container]

    env:
      REGISTRY: ghcr.io

    steps:
      - uses: actions/checkout@v3

      - uses: cachix/install-nix-action@v20
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}

      - uses: cachix/cachix-action@v12
        with:
          name: getchoo
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

      - name: login to ghcr
        if: ${{ matrix.output == 'container' && github.ref == 'refs/heads/main' }}
        uses: docker/login-action@v2
        with:
          registry: ${{ env.REGISTRY }}
          username: "getchoo"
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: build
        run: |
          nix build -L .#${{ matrix.output }}

      - name: upload to ghcr
        if: ${{ matrix.output == 'container' && github.ref == 'refs/heads/main' }}
        run: |
          docker load < result
          docker tag teawiebot:latest ghcr.io/getchoo/teawiebot:latest
          docker push ghcr.io/getchoo/teawiebot:latest