Skip to content

Commit 691c917

Browse files
committed
Add GitHub Actions workflow to build, smoke-test and push image
Build the image on push, PR and release events. Smoke-test it (run with the existing CM_CLIENT_SETTINGS env, sleep, curl, assert the VFB-GA-INJECTED marker is in the served HTML and the configured GA_TAG_ID appears). On push and release events, log in to Docker Hub with the VFB org-level secrets DOCKER_USERNAME and DOCKER_PASSWORD and push. Tags derived via docker/metadata-action: branch refs become :feedGA, :master, etc.; semver-shaped git tags become :1.2.3 and :1.2; PRs get their own :pr-N tag for testability without polluting :feedGA. Action versions pinned to the SHAs used by the rest of VFB (docker-vfb-neo4j-productiondb pattern). The legacy .travis.yml is left in place pending confirmation that GHA is wired up correctly.
1 parent ed6e1fa commit 691c917

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/docker.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Publish Docker image
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
branches: ['**']
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
push_to_registry:
13+
name: Build, smoke-test and push to Docker Hub
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out the repo
17+
uses: actions/checkout@v2
18+
19+
- name: Log in to Docker Hub
20+
if: github.event_name != 'pull_request'
21+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
22+
with:
23+
username: ${{ secrets.DOCKER_USERNAME }}
24+
password: ${{ secrets.DOCKER_PASSWORD }}
25+
26+
- name: Extract metadata (tags, labels) for Docker
27+
id: meta
28+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
29+
with:
30+
images: virtualflybrain/catmaid
31+
tags: |
32+
type=ref,event=branch
33+
type=ref,event=tag
34+
type=ref,event=pr
35+
type=semver,pattern={{version}}
36+
type=semver,pattern={{major}}.{{minor}}
37+
38+
- name: Build image (load locally for smoke test)
39+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
40+
with:
41+
context: .
42+
push: false
43+
load: true
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}
46+
47+
- name: Smoke test
48+
run: |
49+
set -euo pipefail
50+
FIRST_TAG="$(printf '%s\n' "${{ steps.meta.outputs.tags }}" | head -n1)"
51+
CM_SETTINGS='{"neuron-name-service":{"component_list":[{"id":"skeletonid","name":"Skeleton ID"},{"id":"neuronname","name":"Neuron name"},{"id":"all-meta","name":"All annotations annotated with \"neuron name\"","option":"neuron name"}]}}'
52+
docker run -d --name catmaid-test -p 80:80 \
53+
-e INSTANCE_MEMORY=900 \
54+
-e CM_CLIENT_SETTINGS="$CM_SETTINGS" \
55+
-e CM_FORCE_CLIENT_SETTINGS=true \
56+
"$FIRST_TAG"
57+
sleep 120
58+
docker logs catmaid-test
59+
curl -sSf http://localhost:80/ -o /tmp/response.html
60+
echo "--- assert GA snippet was injected ---"
61+
grep -q 'VFB-GA-INJECTED' /tmp/response.html
62+
grep -q "$(docker exec catmaid-test printenv GA_TAG_ID)" /tmp/response.html
63+
64+
- name: Push image
65+
if: github.event_name != 'pull_request'
66+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
67+
with:
68+
context: .
69+
push: true
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)