Skip to content

Merge pull request #59 from Jeruntu/feature/update_beta #2

Merge pull request #59 from Jeruntu/feature/update_beta

Merge pull request #59 from Jeruntu/feature/update_beta #2

name: Build and Push Multi-Platform Docker Image
on:
push:
branches:
- master
jobs:
build-and-push:
runs-on: ubuntu-24.04
strategy:
matrix:
target: ["beta", "stable"]
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER_NAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Extract Version and Set Tag
id: extract_version
run: |
capitalize() {
echo "$1" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}'
}
CAPITALIZED_TARGET=$(capitalize "${{ matrix.target }}")
CONFIG_FILE="Omada ${CAPITALIZED_TARGET}/config.yaml"
VERSION=$(yq '.version' "${CONFIG_FILE}")
DOCKER_IMAGE="${{ secrets.DOCKER_USER_NAME }}/home-assistant-omada"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> $GITHUB_ENV
echo "Target: ${{ matrix.target }}"
echo "Version: $VERSION"
echo "Docker Image: $DOCKER_IMAGE"
- name: Check if Image Exists
id: check_image
run: |
if docker manifest inspect "${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:${{ env.VERSION}}" > /dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Build and Push Docker Image
if: steps.check_image.outputs.exists == 'false'
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--file "./Omada Dev/Dockerfile" \
--tag "${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:${{ env.VERSION }}" \
--push \
--build-arg INSTALL_VER="${{ env.VERSION }}" \
--cache-from "type=registry,ref=${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:cache" \
--cache-to "type=registry,ref=${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:cache,mode=max" \
"./Omada Dev"