-
Notifications
You must be signed in to change notification settings - Fork 24
66 lines (59 loc) · 1.88 KB
/
publish-images.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
64
65
66
name: Build and Push Container Images
on:
push:
branches:
- main
- release-**
tags:
- v*
env:
REGISTRY: ghcr.io
REGISTRY_USER: ${{ github.repository_owner }}
REGISTRY_PATH: ${{ github.repository }}
jobs:
build-and-publish-images:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build images
run: make images
- name: Log in to registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | \
docker login ${{ env.REGISTRY }} -u ${{ env.REGISTRY_USER }} --password-stdin
- name: Push images
run: |
GITREF=${{ github.ref }}
IMAGE_LOCATION=${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}
cd build/images
for tarball in *.tar; do
echo "- Publishing image for tarball $tarball..."
docker load -i $tarball
img=${tarball#nri-}; img=${img%-image*}
sha=${tarball##*-image-}; sha=${sha%.tar}
echo " - image: $img"
echo " - digest: $sha"
echo " - digging out tag from git ref $GITREF..."
case $GITREF in
refs/tags/v*)
tag="${GITREF#refs/tags/v}"
;;
refs/heads/main)
tag=unstable
;;
refs/heads/release-*)
tag="${GITREF#refs/heads/release-}-unstable"
;;
*)
echo "error: can't determine tag."
exit 1
;;
esac
echo " - tag: $tag"
docker tag $sha $IMAGE_LOCATION/nri-$img:$tag
docker push $IMAGE_LOCATION/nri-$img:$tag
done