-
Notifications
You must be signed in to change notification settings - Fork 24
68 lines (58 loc) · 2.21 KB
/
docker-publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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"