Skip to content

Merge pull request #318 from petterip/main #685

Merge pull request #318 from petterip/main

Merge pull request #318 from petterip/main #685

Workflow file for this run

name: Build docker image
on:
push:
pull_request:
workflow_dispatch:
jobs:
golangci:
uses: ./.github/workflows/golangci-lint.yml
test-docker-image:
needs: golangci
# Ubuntu-20.04 required until this is fixed: https://github.com/actions/runner-images/discussions/9074
runs-on: ubuntu-20.04
steps:
- name: Checkout GitHub Action
uses: actions/checkout@v4.1.5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
- name: Build amd64 image for testing
uses: docker/build-push-action@v5.3.0
with:
context: .
tags: birdnet-go:test
load: true
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Install alsa dummy module for testing built image
run: |
sudo apt-get install linux-modules-extra-$(uname -r)
sudo modprobe snd-dummy
- name: Test built amd64 image
run: |
docker run --rm -p 8080:8080 --device /dev/snd --env ALSA_CARD=0 birdnet-go:test realtime --source "Dummy" & p1=$!
if ! wget --retry-connrefused --waitretry=1 --tries=5 -q -O /dev/null http://localhost:8080; then
echo "Failed to reach container after 5 sec"
kill "$p1"
exit 1
else
echo "Container responded to request"
kill "$p1"
fi
push-docker-image:
needs: test-docker-image
if: github.event_name == 'push' && github.ref_name == 'main'
runs-on: ubuntu-20.04
steps:
- name: Checkout GitHub Action
uses: actions/checkout@v4.1.5
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate downcase repository name
run: |
echo "REPO=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
- name: Build and push docker image
uses: docker/build-push-action@v5.3.0
with:
context: .
push: true
tags: |
ghcr.io/${{ env.REPO }}:dev
ghcr.io/${{ env.REPO }}:${{ github.sha }}
platforms: linux/arm64, linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false