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 43d1eee commit 880b42e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 77 deletions.
27 changes: 0 additions & 27 deletions .github/scripts/build-docker-alpine.sh

This file was deleted.

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

This file was deleted.

68 changes: 47 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,18 @@ jobs:
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 }}
Expand Down Expand Up @@ -691,10 +699,17 @@ jobs:
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-alpine.sh "${{ steps.alpine_package.outputs.apk-file }}" "${{ needs.build_details.outputs.branch }}" "${{ matrix.platform }}"
- 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 Down Expand Up @@ -734,14 +749,22 @@ jobs:
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 }}-minimal" "${{ 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 }}-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]
needs: [build_details, build_posix, fetch_s3_artifacts]
if: needs.build_details.outputs.is_fork != 'true'
strategy:
fail-fast: false
Expand All @@ -761,10 +784,6 @@ 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: Login to Docker Hub
if: needs.build_details.outputs.publish_docker_image == 'true'
uses: docker/login-action@v3
Expand All @@ -778,10 +797,17 @@ jobs:
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-alpine.sh "${{ steps.alpine_package.outputs.apk-file }}" "${{ steps.alpine_dbg_package.outputs.apk-file }}" "${{ needs.build_details.outputs.branch }}-minimal" "${{ matrix.platform }}"
- 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 880b42e

Please sign in to comment.