Skip to content

Add labels instance.hetzner.cloud/provided-by,instance.hetzner.cloud/… #91

Add labels instance.hetzner.cloud/provided-by,instance.hetzner.cloud/…

Add labels instance.hetzner.cloud/provided-by,instance.hetzner.cloud/… #91

Workflow file for this run

name: build
on:
push:
branches:
- main
- develop
- 'k8s-v*'
tags:
- 'v*.*.*'
- 'v*.*.*-k8s-v*'
jobs:
docker-build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set env
env:
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
echo "IS_TAG=${IS_TAG}"
if [[ $(echo ${GITHUB_REF#refs/heads/}) == "main" ]]
then
echo "RELEASE_VERSION=latest" >> $GITHUB_ENV
elif [[ $(echo ${GITHUB_REF#refs/heads/}) == "develop" ]]
then
echo "RELEASE_VERSION=latest-develop" >> $GITHUB_ENV
elif [[ ${IS_TAG} == "false" ]]
then
echo "RELEASE_VERSION=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
fi
- name: Login to registry ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to registry docker.io
uses: docker/login-action@v2
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish tag to registry
env:
IMAGE: ${{ github.repository }}
run: |
image=`echo -n "${IMAGE}" | tr 'A-Z' 'a-z'`
echo "${image}:${RELEASE_VERSION}"
docker build -t ghcr.io/${image}:${RELEASE_VERSION} .
docker push ghcr.io/${image}:${RELEASE_VERSION}
docker tag ghcr.io/${image}:${RELEASE_VERSION} docker.io/${image}:${RELEASE_VERSION}
docker push docker.io/${image}:${RELEASE_VERSION}