-
-
Notifications
You must be signed in to change notification settings - Fork 34
106 lines (90 loc) · 2.71 KB
/
docker-publish.yml
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
name: TEI Publisher CI and Docker Snapshots
on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
- 'release/*'
# Publish `v1.2.3` tags as releases.
tags:
- v*
pull_request:
branches: [ master ]
workflow_dispatch:
env:
# TODO: Change variable to your image's name.
IMAGE_NAME: teipublisher
jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Build docker image
run: docker build -t exist-db -f Dockerfile .
- name: Start docker image
run: docker run --publish 8080:8080 --name db --detach exist-db
- name: Run npm install
run: npm install
- name: Run tests
run: npm test
- name: Retrieve eXist log
if: failure()
run: docker cp db:/exist/logs/exist.log .
- name: Publish log as artifact
if: failure()
uses: actions/upload-artifact@v2
with:
name: exist.log
path: ./exist.log
- name: Stop docker
run: docker stop db
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: linux/amd64,linux/arm64
- name: Make buildkit default
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/eeditiones/tei-publisher-app/teipublisher
# TODO(DP): This could be extended further
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
# was ${{ github.actor }}
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
build-args: |
PUBLISHER_VERSION=master
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}