From 9b944c1895726e245b82db4e050e9101f27ecebb Mon Sep 17 00:00:00 2001 From: Elouan Lerissel Date: Mon, 29 Dec 2025 20:06:26 +0100 Subject: [PATCH 1/4] Fix formatting in Dockerfile by removing trailing whitespace --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3cf3ded..aaf002c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,8 +15,8 @@ ARG APP_VERSION RUN apk add --no-cache \ python3 \ wget \ - tar \ - py3-qt6 + tar \ + py3-qt6 # Download LiveboxMonitor RUN wget -qO- https://github.com/p-dor/LiveboxMonitor/archive/refs/tags/${APP_VERSION}.tar.gz | tar -xz --strip-components=1 -C /LiveboxMonitor From c15e0309b876c03440b1d9d4ae73aafca87e2928 Mon Sep 17 00:00:00 2001 From: Elouan Lerissel Date: Tue, 30 Dec 2025 12:16:01 +0100 Subject: [PATCH 2/4] First untested version of the github action --- .github/workflows/build.yaml | 46 +++++++++++++ .github/workflows/publish.yaml | 121 +++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 72 ++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..8ed5f06 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,46 @@ +name: Build + +on: + push: + tags: + - 'v*.*' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + steps: + - uses: actions/checkout@v4 + + - name: Extract version from tag + id: version + run: | + VERSION=${GITHUB_REF#refs/tags/v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build image + uses: docker/build-push-action@v5 + with: + context: . + platforms: ${{ matrix.platform }} + build-args: | + APP_VERSION=${{ steps.version.outputs.version }} + outputs: type=oci,dest=./image-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}.tar + push: false + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: image-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} + path: ./image-*.tar + retention-days: 1 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..69d8923 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,121 @@ +name: Publish + +on: + workflow_run: + workflows: [Test] + types: [completed] + branches: [main] + +env: + REGISTRY_GHCR: ghcr.io + REGISTRY_DOCKER: docker.io + +jobs: + publish: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract version from tag + id: version + run: | + VERSION=${GITHUB_REF#refs/tags/v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "tag=v$VERSION" >> $GITHUB_OUTPUT + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY_GHCR }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY_DOCKER }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata for GHCR + id: meta-ghcr + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_GHCR }}/${{ github.repository_owner }}/liveboxmonitor + tags: | + type=semver,pattern={{version}},value=${{ steps.version.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.version }} + type=raw,value=latest + + - name: Extract metadata for Docker Hub + id: meta-docker + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_DOCKER }}/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor + tags: | + type=semver,pattern={{version}},value=${{ steps.version.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.version }} + type=raw,value=latest + + - name: Build and push to GHCR + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + build-args: | + APP_VERSION=${{ steps.version.outputs.version }} + push: true + tags: ${{ steps.meta-ghcr.outputs.tags }} + labels: ${{ steps.meta-ghcr.outputs.labels }} + + - name: Build and push to Docker Hub + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + build-args: | + APP_VERSION=${{ steps.version.outputs.version }} + push: true + tags: ${{ steps.meta-docker.outputs.tags }} + labels: ${{ steps.meta-docker.outputs.labels }} + + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.tag }} + release_name: Release ${{ steps.version.outputs.version }} + body: | + # LiveboxMonitor Container v${{ steps.version.outputs.version }} + + Built from: [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) + + ## Images Available + + ### GitHub Container Registry + ```bash + docker pull ${{ env.REGISTRY_GHCR }}/${{ github.repository_owner }}/liveboxmonitor:${{ steps.version.outputs.version }} + ``` + + ### Docker Hub + ```bash + docker pull ${{ env.REGISTRY_DOCKER }}/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:${{ steps.version.outputs.version }} + ``` + + ## Upstream Project + - **LiveboxMonitor**: https://github.com/p-dor/LiveboxMonitor + draft: false + prerelease: false diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..02c44af --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,72 @@ +name: Test + +on: + workflow_run: + workflows: [Build] + types: [completed] + branches: [main] + +jobs: + download-and-test: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + strategy: + matrix: + platform: + - amd64 + - arm64 + steps: + - uses: actions/checkout@v4 + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: image-${{ matrix.platform }} + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Load image + run: | + docker load --input ./image-${{ matrix.platform }}.tar + + - name: Extract version from tag + id: version + run: | + VERSION=${GITHUB_REF#refs/tags/v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Run healthcheck + run: | + IMAGE_ID=$(docker images --quiet --filter reference='*/liveboxmonitor:*' | head -1) + if [ -z "$IMAGE_ID" ]; then + echo "Error: No image found" + exit 1 + fi + + # Start container + CONTAINER_ID=$(docker run -d --rm $IMAGE_ID) + echo "Started container: $CONTAINER_ID" + + # Wait for container to be healthy + MAX_ATTEMPTS=10 + ATTEMPT=1 + while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do + STATUS=$(docker inspect --format='{{.State.Health.Status}}' $CONTAINER_ID 2>/dev/null || echo "") + echo "Health check attempt $ATTEMPT: $STATUS" + + if [ "$STATUS" = "healthy" ]; then + echo "Container is healthy!" + docker stop $CONTAINER_ID + exit 0 + fi + + sleep 5 + ATTEMPT=$((ATTEMPT + 1)) + done + + echo "Container failed health check" + docker stop $CONTAINER_ID + exit 1 From 4802da206e80fcef663d5939f1d82bb9b4d1de40 Mon Sep 17 00:00:00 2001 From: Elouan Lerissel Date: Tue, 30 Dec 2025 14:16:10 +0100 Subject: [PATCH 3/4] Implement GitHub Actions for build, test, and publish workflows with version extraction and artifact handling --- .github/workflows/build-test-publish.yaml | 43 +++++++++++ .github/workflows/build.yaml | 32 ++++----- .github/workflows/publish.yaml | 88 ++++++++++------------- .github/workflows/test.yaml | 32 ++++----- 4 files changed, 104 insertions(+), 91 deletions(-) create mode 100644 .github/workflows/build-test-publish.yaml diff --git a/.github/workflows/build-test-publish.yaml b/.github/workflows/build-test-publish.yaml new file mode 100644 index 0000000..d09e164 --- /dev/null +++ b/.github/workflows/build-test-publish.yaml @@ -0,0 +1,43 @@ +name: Build-test-publish + +on: + push: + tags: + - "v*.*" + pull_request: + +jobs: + extract-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.extract.outputs.version }} + steps: + # If pull request, then use 1.6 as version If from a tag, extract version from tag + - name: Extract version + id: extract + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + VERSION="1.6" + else + TAG_NAME="${{ github.ref_name }}" + VERSION="${TAG_NAME#v}" + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + + build: + uses: ./.github/workflows/build.yaml + needs: extract-version + with: + version: ${{ needs.extract-version.outputs.version }} + + test: + uses: ./.github/workflows/test.yaml + needs: build + with: + version: ${{ needs.extract-version.outputs.version }} + + publish: + uses: ./.github/workflows/publish.yaml + needs: test + with: + version: ${{ needs.extract-version.outputs.version }} \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8ed5f06..c6ed262 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,27 +1,19 @@ name: Build on: - push: - tags: - - 'v*.*' + workflow_call: + inputs: + version: + description: 'Version to build' + required: true + type: string jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - platform: - - linux/amd64 - - linux/arm64 steps: - uses: actions/checkout@v4 - - name: Extract version from tag - id: version - run: | - VERSION=${GITHUB_REF#refs/tags/v} - echo "version=$VERSION" >> $GITHUB_OUTPUT - - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -32,15 +24,17 @@ jobs: uses: docker/build-push-action@v5 with: context: . - platforms: ${{ matrix.platform }} + platforms: linux/amd64,linux/arm64 build-args: | - APP_VERSION=${{ steps.version.outputs.version }} - outputs: type=oci,dest=./image-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}.tar + APP_VERSION=${{ inputs.version }} + tags: | + liveboxmonitor:${{ inputs.version }} + outputs: type=oci,dest=./image.tar push: false - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: image-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} - path: ./image-*.tar + name: image-${{ inputs.version }} + path: ./image.tar retention-days: 1 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 69d8923..48d70a4 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,10 +1,12 @@ name: Publish on: - workflow_run: - workflows: [Test] - types: [completed] - branches: [main] + workflow_call: + inputs: + version: + description: 'Version to publish' + required: true + type: string env: REGISTRY_GHCR: ghcr.io @@ -12,7 +14,6 @@ env: jobs: publish: - if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest permissions: contents: write @@ -22,18 +23,13 @@ jobs: with: fetch-depth: 0 - - name: Extract version from tag - id: version - run: | - VERSION=${GITHUB_REF#refs/tags/v} - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "tag=v$VERSION" >> $GITHUB_OUTPUT - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: image-${{ inputs.version }} + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + path: . - name: Log in to GitHub Container Registry uses: docker/login-action@v3 @@ -49,47 +45,35 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Extract metadata for GHCR - id: meta-ghcr - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY_GHCR }}/${{ github.repository_owner }}/liveboxmonitor - tags: | - type=semver,pattern={{version}},value=${{ steps.version.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.version }} - type=raw,value=latest + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - - name: Extract metadata for Docker Hub - id: meta-docker - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY_DOCKER }}/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor - tags: | - type=semver,pattern={{version}},value=${{ steps.version.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.version }} - type=raw,value=latest + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Build and push to GHCR + - name: Load image from artifact + run: | + docker load --input ./image/image.tar + + - name: Push to GitHub Container Registry uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 - build-args: | - APP_VERSION=${{ steps.version.outputs.version }} push: true - tags: ${{ steps.meta-ghcr.outputs.tags }} - labels: ${{ steps.meta-ghcr.outputs.labels }} + tags: | + ${{ env.REGISTRY_GHCR }}/${{ github.repository_owner }}/liveboxmonitor:${{ inputs.version }} + ${{ env.REGISTRY_GHCR }}/${{ github.repository_owner }}/liveboxmonitor:latest - - name: Build and push to Docker Hub + - name: Push to Docker Hub uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 - build-args: | - APP_VERSION=${{ steps.version.outputs.version }} push: true - tags: ${{ steps.meta-docker.outputs.tags }} - labels: ${{ steps.meta-docker.outputs.labels }} + tags: | + ${{ env.REGISTRY_DOCKER }}/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:${{ inputs.version }} + ${{ env.REGISTRY_DOCKER }}/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:latest - name: Create Release uses: actions/create-release@v1 @@ -103,17 +87,17 @@ jobs: Built from: [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) - ## Images Available + ## Images Available at : ### GitHub Container Registry - ```bash - docker pull ${{ env.REGISTRY_GHCR }}/${{ github.repository_owner }}/liveboxmonitor:${{ steps.version.outputs.version }} - ``` + + - `/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:${{ steps.version.outputs.version }}` + - `/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:latest` ### Docker Hub - ```bash - docker pull ${{ env.REGISTRY_DOCKER }}/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:${{ steps.version.outputs.version }} - ``` + + - `/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:${{ steps.version.outputs.version }}` + - `/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:latest` ## Upstream Project - **LiveboxMonitor**: https://github.com/p-dor/LiveboxMonitor diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 02c44af..777caca 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,14 +1,15 @@ name: Test on: - workflow_run: - workflows: [Build] - types: [completed] - branches: [main] + workflow_call: + inputs: + version: + description: 'Version to test' + required: true + type: string jobs: download-and-test: - if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest strategy: matrix: @@ -21,33 +22,24 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: image-${{ matrix.platform }} + name: image-${{ inputs.version }} github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ github.event.workflow_run.id }} + path: . - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Load image run: | - docker load --input ./image-${{ matrix.platform }}.tar - - - name: Extract version from tag - id: version - run: | - VERSION=${GITHUB_REF#refs/tags/v} - echo "version=$VERSION" >> $GITHUB_OUTPUT + docker load --input ./image/image.tar - name: Run healthcheck run: | - IMAGE_ID=$(docker images --quiet --filter reference='*/liveboxmonitor:*' | head -1) - if [ -z "$IMAGE_ID" ]; then - echo "Error: No image found" - exit 1 - fi - + IMAGE_TAG=liveboxmonitor:${{ inputs.version }} + # Start container - CONTAINER_ID=$(docker run -d --rm $IMAGE_ID) + CONTAINER_ID=$(docker run -d --rm --platform linux/${{ matrix.platform }} $IMAGE_TAG) echo "Started container: $CONTAINER_ID" # Wait for container to be healthy From 13ad253bc4c8e6ca060fa9dee02aa69567c3c5c4 Mon Sep 17 00:00:00 2001 From: Elouan Lerissel Date: Tue, 30 Dec 2025 14:18:00 +0100 Subject: [PATCH 4/4] Add permissions section to GitHub Actions workflow for build-test-publish --- .github/workflows/build-test-publish.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-test-publish.yaml b/.github/workflows/build-test-publish.yaml index d09e164..35c7150 100644 --- a/.github/workflows/build-test-publish.yaml +++ b/.github/workflows/build-test-publish.yaml @@ -6,6 +6,10 @@ on: - "v*.*" pull_request: +permissions: + contents: write + packages: write + jobs: extract-version: runs-on: ubuntu-latest