name: docker on: push: tags: - "v*" pull_request: branches: - "main" env: slug: "klutchell/unbound" platforms: "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6" images: "docker.io/klutchell/unbound,ghcr.io/klutchell/unbound" local_tag: localhost:5000/klutchell/unbound:latest jobs: build: runs-on: ubuntu-20.04 services: registry: image: registry:2.7.1 ports: - 5000:5000 steps: - uses: actions/checkout@v2 - id: meta uses: docker/metadata-action@v3 with: images: ${{ env.images }} tags: | type=ref,event=tag type=ref,event=branch type=ref,event=pr type=sha - uses: docker/setup-buildx-action@v1 with: driver-opts: network=host - uses: docker/build-push-action@v2 with: platforms: ${{ env.platforms }} labels: ${{ steps.meta.outputs.labels }} tags: ${{ env.local_tag }} cache-to: type=gha,mode=max cache-from: | type=gha ${{ steps.meta.outputs.tags }} docker.io/${{ env.slug }}:latest ghcr.io/${{ env.slug }}:latest push: true - uses: docker/setup-qemu-action@v1 - name: Test functionality run: | for platform in $(tr ',' '\n' <<< "${{ env.platforms }}") ; do export IMAGE=${{ env.local_tag }} export PLATFORM="${platform}" docker-compose pull docker-compose up version | tee /dev/stderr | grep -wq "$(head -n1 VERSION)" docker-compose up sigok | tee /dev/stderr | grep -wq NOERROR || { docker-compose logs ; exit 1 ; } docker-compose up sigfail | tee /dev/stderr | grep -wq SERVFAIL || { docker-compose logs ; exit 1 ; } docker-compose down --rmi all done - uses: docker/login-action@v1 if: github.actor == github.repository_owner with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/login-action@v1 if: github.actor == github.repository_owner with: registry: docker.io username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - uses: akhilerm/tag-push-action@v2.0.0 if: github.actor == github.repository_owner with: src: ${{ env.local_tag }} dst: | ${{ steps.meta.outputs.tags }} - uses: peter-evans/dockerhub-description@v2 if: github.event_name != 'pull_request' with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} repository: ${{ env.slug }}