-
-
Notifications
You must be signed in to change notification settings - Fork 35
192 lines (162 loc) · 5.9 KB
/
docker-publish.yml
File metadata and controls
192 lines (162 loc) · 5.9 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Deploy Docker
on:
push:
# Publish `main` and `master` as Docker `latest` image.
branches:
- main
- master
- 'release/*'
# Publish `v1.2.3` tags as releases.
tags:
- v*
pull_request:
branches: [ main, master ]
workflow_dispatch:
env:
IMAGE_NAME: teipublisher
DEMO_IMAGE: ghcr.io/eeditiones/jinks-demo
TEST_TAG: exist-db
jobs:
# Run tests against the demo image from jinks repo
test:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
EXIST_BASE: [6.2.0, release]
experimental: [false]
include:
- EXIST_BASE: latest
experimental: true
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull demo image
run: docker pull ${{ env.DEMO_IMAGE }}:latest
- name: Start demo container
run: |
docker run -d \
--name teipublisher-test \
--publish 8080:8080 \
${{ env.DEMO_IMAGE }}:latest
- name: Wait for server to be ready
run: |
echo "Waiting for eXist-db to start..."
timeout=120
elapsed=0
while [ $elapsed -lt $timeout ]; do
if curl -s -f http://localhost:8080/exist/apps/tei-publisher/ > /dev/null 2>&1; then
echo "Server is ready!"
exit 0
fi
echo "Still waiting... ($elapsed seconds)"
sleep 5
elapsed=$((elapsed + 5))
done
echo "Timeout waiting for server"
exit 1
# Setup Node.js (needed for Ant build which calls npm install)
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "lts/*"
cache: 'npm'
- name: Run npm install
run: npm install
- name: Run tests
if: matrix.experimental != true
run: npx cypress run --browser firefox
- name: Run tests [expect failures]
if: matrix.experimental == true
continue-on-error: true
run: npx cypress run --browser firefox
- name: Retrieve eXist log
if: failure()
run: docker cp teipublisher-test:/exist/logs/exist.log .
- name: Publish log as artifact
if: failure()
uses: actions/upload-artifact@v7
with:
name: exist-${{matrix.EXIST_BASE}}-teipublisher.log
path: ./exist.log
- name: Stop container
if: always()
run: docker stop teipublisher-test || true
# Push demo image to both registries as teipublisher
push:
# Ensure test job passes before pushing image.
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull demo image
run: docker pull ${{ env.DEMO_IMAGE }}:latest
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/eeditiones/${{ env.IMAGE_NAME }}
existdb/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern=v{{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Add latest tag for releases
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo -e "${{ steps.meta.outputs.tags }}\nlatest" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
id: tags_with_latest
- name: Push to GHCR
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
run: |
# Use buildx imagetools to copy multi-arch manifest for each tag
echo "${{ steps.tags_with_latest.outputs.tags || steps.meta.outputs.tags }}" | while IFS= read -r tag; do
if [ -n "$tag" ]; then
# Extract tag-only (substring after last ':')
short_tag="${tag##*:}"
echo "Pushing ghcr.io/eeditiones/${{ env.IMAGE_NAME }}:$short_tag"
docker buildx imagetools create -t "ghcr.io/eeditiones/${{ env.IMAGE_NAME }}:$short_tag" ${{ env.DEMO_IMAGE }}:latest
fi
done
- name: Push to Docker Hub
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
run: |
# Use buildx imagetools to copy multi-arch manifest for each tag
echo "${{ steps.tags_with_latest.outputs.tags || steps.meta.outputs.tags }}" | while IFS= read -r tag; do
if [ -n "$tag" ]; then
# Extract tag-only (substring after last ':')
short_tag="${tag##*:}"
echo "Pushing existdb/${{ env.IMAGE_NAME }}:$short_tag"
docker buildx imagetools create -t "existdb/${{ env.IMAGE_NAME }}:$short_tag" ${{ env.DEMO_IMAGE }}:latest
fi
done