Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/build-test-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build-test-publish

on:
push:
tags:
- "v*.*"
pull_request:

permissions:
contents: write
packages: write

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 }}
40 changes: 40 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build

on:
workflow_call:
inputs:
version:
description: 'Version to build'
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- 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: linux/amd64,linux/arm64
build-args: |
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-${{ inputs.version }}
path: ./image.tar
retention-days: 1
105 changes: 105 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Publish

on:
workflow_call:
inputs:
version:
description: 'Version to publish'
required: true
type: string

env:
REGISTRY_GHCR: ghcr.io
REGISTRY_DOCKER: docker.io

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- 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
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: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- 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
push: true
tags: |
${{ env.REGISTRY_GHCR }}/${{ github.repository_owner }}/liveboxmonitor:${{ inputs.version }}
${{ env.REGISTRY_GHCR }}/${{ github.repository_owner }}/liveboxmonitor:latest

- name: Push to Docker Hub
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
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
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 at :

### GitHub Container Registry

- `/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:${{ steps.version.outputs.version }}`
- `/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:latest`

### Docker Hub

- `/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:${{ steps.version.outputs.version }}`
- `/${{ secrets.DOCKER_USERNAME }}/liveboxmonitor:latest`

## Upstream Project
- **LiveboxMonitor**: https://github.com/p-dor/LiveboxMonitor
draft: false
prerelease: false
64 changes: 64 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Test

on:
workflow_call:
inputs:
version:
description: 'Version to test'
required: true
type: string

jobs:
download-and-test:
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-${{ 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/image.tar

- name: Run healthcheck
run: |
IMAGE_TAG=liveboxmonitor:${{ inputs.version }}

# Start container
CONTAINER_ID=$(docker run -d --rm --platform linux/${{ matrix.platform }} $IMAGE_TAG)
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading