Skip to content

Commit 7efeb69

Browse files
committed
update workflow to build image on github
1 parent 14b3000 commit 7efeb69

3 files changed

Lines changed: 78 additions & 22 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-push:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Log in to GitHub Container Registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ghcr.io/${{ github.repository_owner }}/homespeaker
37+
tags: |
38+
type=ref,event=tag
39+
type=raw,value=latest
40+
41+
- name: Build and push ARM64 image
42+
uses: docker/build-push-action@v5
43+
with:
44+
context: .
45+
file: ./HomeSpeaker.Server2/Dockerfile
46+
platforms: linux/arm64
47+
push: true
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
cache-from: type=gha
51+
cache-to: type=gha,mode=max
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
name: Docker Image CI
1+
name: Deploy to Raspberry Pi
22

33
on:
4-
workflow_dispatch:
5-
push:
6-
tags:
7-
- '*'
8-
# To have GitHub Actions deploy a new version, create a new tag
9-
# git tag -a yyyy.m.d -m yyyy.m.d
10-
# Then push those tags
11-
# git push --tags
12-
# Then a new version will be deployed on the self-hosted runner.
4+
workflow_run:
5+
workflows: ["Build and Push Docker Images"]
6+
types:
7+
- completed
8+
workflow_dispatch:
139

1410
jobs:
15-
Build-and-Deploy:
11+
deploy:
1612
runs-on: [self-hosted, "${{ matrix.runner}}" ]
13+
# Only deploy if the build workflow succeeded
14+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
1715
strategy:
1816
matrix:
1917
include:
@@ -25,6 +23,10 @@ jobs:
2523
steps:
2624
- uses: actions/checkout@v4
2725

26+
- name: Log in to GitHub Container Registry
27+
run: |
28+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
29+
2830
- name: Renew Tailscale certificate
2931
run: |
3032
cd ~/cert
@@ -41,26 +43,27 @@ jobs:
4143
cat > .env << EOF
4244
GOVEE_API_KEY=${GOVEE_API_KEY}
4345
AIRPLAY_NAME=${AIRPLAY_NAME}
46+
HOMESPEAKER_IMAGE=ghcr.io/${{ github.repository_owner }}/homespeaker:latest
4447
EOF
4548
46-
- name: Docker compose pull
49+
- name: Pull latest images
4750
run: docker-compose pull
4851

49-
- name: Docker compose down
52+
- name: Stop containers
5053
run: docker-compose down
5154

52-
- name: Docker compose up
53-
env:
54-
COMPOSE_DOCKER_CLI_BUILD: 1
55-
DOCKER_BUILDKIT: 1
56-
run: docker-compose up -d --build --remove-orphans
55+
- name: Start containers (no build!)
56+
run: docker-compose up -d --remove-orphans
5757

5858
- name: Wait for services to be ready
5959
run: sleep 25
6060

6161
- name: Refresh browser on touchscreen
6262
run: |
6363
export DISPLAY=:0
64-
xdotool key F5
65-
continue-on-error:
66-
true
64+
xdotool key F5
65+
continue-on-error: true
66+
67+
- name: Clean up old images
68+
run: docker image prune -af --filter "until=168h"
69+
continue-on-error: true

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ version: '3.4'
22
services:
33
homespeaker.server2:
44
container_name: homespeaker
5-
image: homespeakerserver2
5+
# Use pre-built image from GitHub Container Registry
6+
# Falls back to local build if image not available
7+
image: ${HOMESPEAKER_IMAGE:-ghcr.io/snow-jallen/homespeaker:latest}
68
build:
79
context: .
810
dockerfile: HomeSpeaker.Server2/Dockerfile

0 commit comments

Comments
 (0)