62 lines
1.7 KiB
YAML
62 lines
1.7 KiB
YAML
name: Build Docker image
|
|
|
|
on:
|
|
push:
|
|
branches: main
|
|
tags:
|
|
- v*
|
|
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
buildx:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Prepare
|
|
id: prep
|
|
run: |
|
|
DOCKER_IMAGE=keshavdv/unifi-cam-proxy
|
|
VERSION=dev
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
VERSION=${GITHUB_REF#refs/tags/v}
|
|
fi
|
|
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
|
if [ "${{ github.event_name }}" = "push" ]; then
|
|
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
|
|
fi
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
|
|
fi
|
|
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
|
|
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
|
|
push: true
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
labels: |
|
|
org.opencontainers.image.source=${{ github.event.repository.html_url }}
|
|
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|