Merge branch 'master' into codex/add-post-build-test-for-docker-image #1130
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
submodules: true | |
- uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 | |
- uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 | |
- name: Login to dockerhub | |
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GitHub | |
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- id: docker_meta | |
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
${{ github.repository }} | |
flavor: | | |
latest=true | |
tags: | | |
type=sha,format=long | |
type=edge,branch=$repo.default_branch | |
- name: build+push | |
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
with: | |
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 | |
push: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
- name: build image for tests | |
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
with: | |
platforms: linux/amd64 | |
load: true | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
- name: run integration test | |
shell: bash | |
run: | | |
IMAGE=$(echo "${{ steps.docker_meta.outputs.tags }}" | head -n 1) | |
docker run -d --name sonos-test -p 5005:5005 "$IMAGE" | |
for i in {1..20}; do | |
if curl -fs http://localhost:5005/zones > /dev/null; then | |
success=true | |
break | |
fi | |
sleep 3 | |
done | |
docker rm -f sonos-test | |
if [ "$success" != "true" ]; then | |
echo "Endpoint test failed" >&2 | |
exit 1 | |
fi |