Skip to content

trigger on tag too

trigger on tag too #90

Workflow file for this run

name: build
on:
push:
branches:
- 'v1-main'
tags:
- '*'
paths-ignore:
- 'docs/**'
- 'deploy/**'
- '*.md'
- '*.yaml'
- '*.sh'
pull_request:
branches:
- 'v1-main'
jobs:
docker-build:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message,'[skip ci]') }}
steps:
- uses: actions/checkout@v3
- name: set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: decide on tag
id: prep
run: |
DOCKER_IMAGE=${{ github.repository }}
VERSION=noop
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=edge
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: build and push
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
platforms: |
linux/amd64
linux/arm64
tags: ${{ steps.prep.outputs.tags }}
- name: image digest
run: echo ${{ steps.docker_build.outputs.digest }}