summaryrefslogtreecommitdiff
path: root/.github/workflows/upload.yaml
blob: 0f69606a7212c57dbb9627506bd1573e21ea94b1 (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
name: upload to registry
# this is for uploading images to a container registry when
# changes are made to `main`

on:
  check_suite:
    types: [completed]

permissions:
  packages: write

jobs:
  upload:
    runs-on: ubuntu-latest

    env:
      REGISTRY: ghcr.io
      USERNAME: getchoo

    steps:
      - uses: actions/checkout@v3
      - uses: cachix/install-nix-action@v22

      - name: fetch docker image
        run: |
          nix build --accept-flake-config -L .#container
          readlink result | xargs -I {} cp {} teawiebot.tar.gz

      - name: login to registry
        uses: docker/login-action@v2
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ env.USERNAME }}
          password: ${{ github.token }}

      - name: upload to registry
        env:
          PUSH_PREFIX: ${{ env.REGISTRY }}/${{ env.USERNAME }}
        run: |
          docker load < teawiebot.tar.gz
          docker tag teawiebot:latest ${{ env.PUSH_PREFIX }}/teawiebot:latest
          docker push ${{ env.PUSH_PREFIX }}/teawiebot:latest