Skip to content

Fix tests

Fix tests #787

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@v4
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 }}