Merge pull request #312 from klihub/fixes/flip-class-node-critical #250
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Container Images | |
on: | |
push: | |
branches: | |
- main | |
- release-* | |
tags: | |
- v[0-9]+.[0-9]+.[0-9]+ | |
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@v4 | |
- 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/}" | |
;; | |
refs/heads/main) | |
tag=unstable | |
;; | |
refs/heads/release-*) | |
tag="v${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 |