Skip to content

Commit

Permalink
refactor(ci): Use docker/build-push-action to build docker images
Browse files Browse the repository at this point in the history
Replace the build-docker.sh script with a GitHub action to standardize
the ci workflow and reduce complexity.
  • Loading branch information
vitoyucepi committed Jan 8, 2025
1 parent 5042b4d commit b2c29f9
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 95 deletions.
27 changes: 0 additions & 27 deletions .github/scripts/build-docker-alpine.sh

This file was deleted.

32 changes: 0 additions & 32 deletions .github/scripts/build-docker.sh

This file was deleted.

120 changes: 84 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -645,21 +645,28 @@ jobs:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
# if: needs.build_details.outputs.publish_docker_image == 'true'
if: needs.build_details.outputs.publish_docker_image == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
env:
PUBLISH_DOCKER_IMAGE: ${{ needs.build_details.outputs.publish_docker_image }}
run: .github/scripts/build-docker.sh "${{ steps.debian_package.outputs.deb-file }}" "${{ steps.debian_debug_package.outputs.deb-file }}" "${{ needs.build_details.outputs.branch }}" "${{ matrix.platform }}"
- name: Build and push docker image
uses: docker/build-push-action@v6
with:
build-args: |
"DEB_FILE=${{ steps.debian_package.outputs.deb-file }}"
"DEB_DEBUG_FILE=${{ steps.debian_debug_package.outputs.deb-file }}"
context: .
file: .github/docker/debian.dockerfile
tags: |
"savonet/liquidsoap-ci-build:${{ needs.build_details.outputs.branch }}_${{ matrix.platform }}"
"ghcr.io/savonet/liquidsoap-ci-build:${{ needs.build_details.outputs.branch }}_${{ matrix.platform }}"
push: ${{ needs.build_details.outputs.publish_docker_image }}

build_docker_alpine:
runs-on: ${{ matrix.runs-on }}
needs: [build_details, build_posix, fetch_s3_artifacts]
if: needs.build_details.outputs.is_fork != 'true'
strategy:
fail-fast: false
matrix:
Expand All @@ -678,15 +685,30 @@ jobs:
run: |
echo "apk-file=$(find artifacts/${{ needs.build_details.outputs.sha }} -type f | grep -v minimal | grep 'apk$' | grep -v dbg | grep ${{ matrix.alpine-arch }})" >> "${GITHUB_OUTPUT}"
id: alpine_package
- name: Log in to container registries
- name: Login to Docker Hub
if: needs.build_details.outputs.publish_docker_image == 'true'
run: |
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USER }}" --password-stdin
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u "${{ github.actor }}" --password-stdin ghcr.io
- name: Build docker image
env:
PUBLISH_DOCKER_IMAGE: ${{ needs.build_details.outputs.publish_docker_image }}
run: .github/scripts/build-docker-alpine.sh "${{ steps.alpine_package.outputs.apk-file }}" "${{ needs.build_details.outputs.branch }}" "${{ matrix.platform }}"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
if: needs.build_details.outputs.publish_docker_image == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v6
with:
build-args: |
"APK_FILE=${{ steps.alpine_package.outputs.apk-file }}"
context: .
file: .github/docker/alpine.dockerfile
tags: |
"savonet/liquidsoap-ci-build:${{ needs.build_details.outputs.branch }}_alpine_${{ matrix.platform }}"
"ghcr.io/savonet/liquidsoap-ci-build:${{ needs.build_details.outputs.branch }}_alpine_${{ matrix.platform }}"
push: ${{ needs.build_details.outputs.publish_docker_image }}

build_docker_minimal:
runs-on: ${{ matrix.runs-on }}
Expand All @@ -713,20 +735,35 @@ jobs:
run: |
echo "deb-file=$(find artifacts/${{ needs.build_details.outputs.sha }} -type f | grep ${{ matrix.docker-debian-os }} | grep minimal | grep '${{ matrix.platform }}\.deb$' | grep dbgsym | grep deb)" >> "${GITHUB_OUTPUT}"
id: debian_debug_package
- name: Log in to container registries
- name: Login to Docker Hub
if: needs.build_details.outputs.publish_docker_image == 'true'
run: |
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USER }}" --password-stdin
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u "${{ github.actor }}" --password-stdin ghcr.io
- name: Build docker image
env:
PUBLISH_DOCKER_IMAGE: ${{ needs.build_details.outputs.publish_docker_image }}
run: .github/scripts/build-docker.sh "${{ steps.debian_package.outputs.deb-file }}" "${{ steps.debian_debug_package.outputs.deb-file }}" "${{ needs.build_details.outputs.branch }}-minimal" "${{ matrix.platform }}"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
if: needs.build_details.outputs.publish_docker_image == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v6
with:
build-args: |
"DEB_FILE=${{ steps.debian_package.outputs.deb-file }}"
"DEB_DEBUG_FILE=${{ steps.debian_debug_package.outputs.deb-file }}"
context: .
file: .github/docker/debian.dockerfile
tags: |
"savonet/liquidsoap-ci-build:${{ needs.build_details.outputs.branch }}-minimal_${{ matrix.platform }}"
"ghcr.io/savonet/liquidsoap-ci-build:${{ needs.build_details.outputs.branch }}-minimal_${{ matrix.platform }}"
push: ${{ needs.build_details.outputs.publish_docker_image }}

build_docker_alpine_minimal:
runs-on: ${{ matrix.runs-on }}
needs: [build_details, run_tests, build_posix, fetch_s3_artifacts]
if: needs.build_details.outputs.is_fork != 'true'
needs: [build_details, build_posix, fetch_s3_artifacts]
strategy:
fail-fast: false
matrix:
Expand All @@ -745,19 +782,30 @@ jobs:
run: |
echo "apk-file=$(find artifacts/${{ needs.build_details.outputs.sha }} -type f | grep minimal | grep 'apk$' | grep -v dbg | grep ${{ matrix.alpine-arch }})" >> "${GITHUB_OUTPUT}"
id: alpine_package
- name: Get alpine debug package
run: |
echo "apk-file=$(find artifacts/${{ needs.build_details.outputs.sha }} -type f | grep minimal | grep 'apk$' | grep dbg | grep ${{ matrix.alpine-arch }})" >> "${GITHUB_OUTPUT}"
id: alpine_dbg_package
- name: Log in to container registries
- name: Login to Docker Hub
if: needs.build_details.outputs.publish_docker_image == 'true'
run: |
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USER }}" --password-stdin
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u "${{ github.actor }}" --password-stdin ghcr.io
- name: Build docker image
env:
PUBLISH_DOCKER_IMAGE: ${{ needs.build_details.outputs.publish_docker_image }}
run: .github/scripts/build-docker-alpine.sh "${{ steps.alpine_package.outputs.apk-file }}" "${{ steps.alpine_dbg_package.outputs.apk-file }}" "${{ needs.build_details.outputs.branch }}-minimal" "${{ matrix.platform }}"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
if: needs.build_details.outputs.publish_docker_image == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v6
with:
build-args: |
"APK_FILE=${{ steps.alpine_package.outputs.apk-file }}"
context: .
file: .github/docker/alpine.dockerfile
tags: |
"savonet/liquidsoap-ci-build:${{ needs.build_details.outputs.branch }}-minimal_alpine_${{ matrix.platform }}"
"ghcr.io/savonet/liquidsoap-ci-build:${{ needs.build_details.outputs.branch }}-minimal_alpine_${{ matrix.platform }}"
push: ${{ needs.build_details.outputs.publish_docker_image }}

build_docker_release:
runs-on: ubuntu-latest
Expand Down

0 comments on commit b2c29f9

Please sign in to comment.