Skip to content

Commit 88d0d6e

Browse files
committed
feat (CI): add new github-docker CI workflow to build, test and push images
1 parent 5a3948b commit 88d0d6e

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

.github/workflows/docker-ci.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Build, Test & Push images
2+
3+
on:
4+
push:
5+
tags:
6+
- "*.*.*" # e.g., 1.0.0, 2.1.3
7+
workflow_dispatch:
8+
9+
env:
10+
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
11+
PLATFORMS: ${{ vars.PLATFORMS }}
12+
13+
jobs:
14+
build-test-push:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
fail-fast: true
19+
matrix:
20+
include:
21+
- variant: debian
22+
dockerfile: ./debian.dockerfile
23+
tag: debian
24+
latest: true
25+
- variant: alpine
26+
dockerfile: ./alpine.dockerfile
27+
tag: alpine
28+
latest: false
29+
30+
steps:
31+
- name: Check out repository
32+
uses: actions/checkout@v4
33+
34+
- name: Set up QEMU
35+
uses: docker/setup-qemu-action@v3
36+
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Log in to Docker Hub
41+
uses: docker/login-action@v3
42+
with:
43+
username: ${{ secrets.DOCKER_USERNAME }}
44+
password: ${{ secrets.DOCKER_PASSWORD }}
45+
46+
- name: Determine tag name
47+
id: vars
48+
run: echo "VERSION_TAG=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
49+
50+
- name: Extract OCI metadata
51+
id: meta
52+
uses: docker/metadata-action@v5
53+
with:
54+
images: ${{ env.IMAGE_NAME }}
55+
tags: |
56+
type=raw,value=${{ matrix.tag }}
57+
type=raw,value=${{ matrix.tag }}-${{ steps.vars.outputs.VERSION_TAG }}
58+
${{ matrix.latest && format('type=raw,value=latest') || '' }}
59+
labels: |
60+
org.opencontainers.image.title=VNC Browser (${{ matrix.tag }})
61+
org.opencontainers.image.version=${{ steps.vars.outputs.VERSION_TAG }}
62+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
63+
org.opencontainers.image.revision=${{ github.sha }}
64+
65+
- name: Build ${{ matrix.variant }} image
66+
uses: docker/build-push-action@v6
67+
with:
68+
context: .
69+
file: ${{ matrix.dockerfile }}
70+
platforms: ${{ env.PLATFORMS }}
71+
push: false
72+
load: true
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max
77+
78+
- name: Test container startup
79+
run: |
80+
docker run -d --rm --name test-${{ matrix.tag }} \
81+
-p 5900:5900 -p 6080:6080 \
82+
-e VNC_PASSWORD=testpass \
83+
${{ env.IMAGE_NAME }}:${{ matrix.tag }}
84+
echo "Waiting for container to start..."
85+
sleep 10
86+
docker ps
87+
curl -sSf http://localhost:6080 > /dev/null
88+
echo "Test passed for ${{ matrix.tag }}"
89+
90+
- name: Push image
91+
uses: docker/build-push-action@v6
92+
with:
93+
context: .
94+
file: ${{ matrix.dockerfile }}
95+
platforms: ${{ env.PLATFORMS }}
96+
push: true
97+
tags: ${{ steps.meta.outputs.tags }}
98+
labels: ${{ steps.meta.outputs.labels }}
99+
cache-from: type=gha
100+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)