-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (48 loc) · 2.04 KB
/
docker.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
name: Docker
permissions:
packages: write
on:
push:
branches: [ "main" ]
tags: [ "*.*.*" ]
pull_request:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare nix
uses: cachix/install-nix-action@v18
with:
extra_nix_config: |
accept-flake-config = true
substituters = https://cache.iog.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
allow-import-from-derivation = true
- name: Build images using nix
run: |
IMAGE_NAME=ghcr.io/${{github.repository_owner}}/easy-bi-server
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
nix build .#docker.easy-bi-server && docker load < ./result
echo "FROM easy-bi-server" | docker build \
--label org.opencontainers.image.source=https://github.com/j-mueller/easy-bi \
--label org.opencontainers.image.licenses=Apache-2.0 \
--label org.opencontainers.image.created=$(date -Is) \
--label org.opencontainers.image.revision=${{github.sha}} \
--label org.opencontainers.image.version=unstable \
--tag ${IMAGE_NAME}:unstable -
# Also tag with semver if we are building a tag
building_tag=${{github.ref_type == 'tag'}}
[[ ${building_tag} = true ]] && \
docker tag ${IMAGE_NAME}:unstable ${IMAGE_NAME}:${{github.ref_name}}
docker images
docker inspect ${IMAGE_NAME}:unstable
- name: Push image to container registry
run: docker push -a ${IMAGE_NAME}