78 lines
2.5 KiB
YAML
78 lines
2.5 KiB
YAML
name: Publish Docker image
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
- 'beta'
|
|
- 'hotfix/*'
|
|
tags:
|
|
- 'v*.*.*'
|
|
|
|
env:
|
|
TEST_TAG: jacobalberty/unifi:test
|
|
PKGURL: https://dl.ui.com/unifi/6.5.55/unifi_sysvinit_all.deb
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: all
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
- name: Login to GitHub Container Resgistry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
- name: Build and export to Docker
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
load: true
|
|
tags: ${{ env.TEST_TAG }}
|
|
- name: Test image
|
|
run: |
|
|
export PKGURL=${{env.PKGURL}} &&
|
|
docker run -d --env PKGURL --rm --name unifitest ${{env.TEST_TAG}} &&
|
|
sleep 35 &&
|
|
for i in $(seq 1 10); do [ $(docker inspect --format='{{json .State.Health.Status}}' unifitest ) == \"healthy\" ] && break || sleep 35; done &&
|
|
[ $(docker inspect --format='{{json .State.Health.Status}}' unifitest ) == \"healthy\" ] &&
|
|
docker stop unifitest
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
tags: |
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
type=semver,pattern=v{{version}}
|
|
type=semver,pattern=v{{major}}
|
|
type=semver,pattern=v{{major}}.{{minor}}
|
|
type=ref,event=branch
|
|
images: |
|
|
jacobalberty/unifi
|
|
ghcr.io/${{ github.repository }}
|
|
- name: Build container image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
provenance: false
|
|
platforms: linux/arm64/v8,linux/amd64
|
|
push: true
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.tags }}
|
|
- name: Image digest
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|