diff --git a/.github/workflows/docker-image-push.yml b/.github/workflows/docker-image-push.yml index 4bf3907..03462b2 100644 --- a/.github/workflows/docker-image-push.yml +++ b/.github/workflows/docker-image-push.yml @@ -1,6 +1,8 @@ -name: Build (and push) multi-arch Docker image +name: Build and push multi-arch Docker image -on: [push, pull_request] +on: + release: + types: [published] jobs: build: @@ -16,46 +18,23 @@ jobs: uses: actions/checkout@v1 - name: Docker login - if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} run: echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin docker.io - - name: Setup buildx - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - docker buildx create --use + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + install: true - name: Build Docker image env: PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7 DOCKER_REPOSITORY: thelounge/thelounge - run: | - TAG="$(git rev-parse --short HEAD)" - EXTRA_ARG=() - # Only push on regular push (!= pull_request) - if [ "${GITHUB_EVENT_NAME}" = "push" ] && grep -q "^refs/tags/" <<< "${GITHUB_REF}"; then - EXTRA_ARG+=("--push") - VERSION="$(git describe --exact-match --tags)" - TAG="${VERSION}" - MAJOR_TAG="$(echo "$VERSION" | sed -nre 's/^([0-9]+).*/\1/p')" - LATEST_TAG="latest" - if grep -q "^alpine/" <<< "${{ matrix.dockerfile }}"; then - TAG="${TAG}-alpine" - MAJOR_TAG="${MAJOR_TAG}-alpine" - LATEST_TAG="alpine" - fi - # If not a pre-release push LATEST_TAG & MAJOR_TAG - if grep -qE "^[0-9]*\.[0-9]*\.[0-9]*$" <<< "${VERSION}"; then - EXTRA_ARG+=("--tag" "${DOCKER_REPOSITORY}:${LATEST_TAG}") - EXTRA_ARG+=("--tag" "${DOCKER_REPOSITORY}:${MAJOR_TAG}") - fi - fi - docker buildx build \ - --platform "${PLATFORMS}" \ - --tag "${DOCKER_REPOSITORY}:${TAG}" \ - "${EXTRA_ARG[@]}" \ - --file "${{ matrix.dockerfile }}" \ - . + DOCKERFILE: ${{ matrix.dockerfile }} + run: ./scripts/build-and-push.sh diff --git a/.github/workflows/docker-image-test.yml b/.github/workflows/docker-image-test.yml index c0653c7..c560386 100644 --- a/.github/workflows/docker-image-test.yml +++ b/.github/workflows/docker-image-test.yml @@ -7,32 +7,53 @@ jobs: name: Build runs-on: ubuntu-latest strategy: + fail-fast: false matrix: + platform: [linux/amd64, linux/arm64/v8, linux/arm/v7] dockerfile: [Dockerfile, alpine/Dockerfile] steps: - name: Set env run: echo "mount_dir=$(mktemp -d)" >> $GITHUB_ENV - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + install: true - name: Build Docker image - run: docker build -t thelounge -f ${{ matrix.dockerfile }} . + run: docker build --platform ${{ matrix.platform }} --load -t thelounge -f ${{ matrix.dockerfile }} . - name: Start Docker container - run: docker run --user "$UID" -v "${mount_dir}:/var/opt/thelounge" -d -p 9001:9000 --name thelounge thelounge + run: docker run --platform ${{ matrix.platform }} --user "$UID" -v "${mount_dir}:/var/opt/thelounge" -d -p 9001:9000 --name thelounge thelounge - name: Check TheLounge version run: docker exec thelounge thelounge --version | grep --color=never -E "^v[0-9]\.[0-9]\.[0-9]" | cut -c 2- | grep -f /dev/stdin ${{ matrix.dockerfile }} - - name: Wait for server to (hopefully) start - run: sleep 3 - - name: Check HTML output - run: curl -sL localhost:9001 | grep "