fix: Filepond upload util (#39) #152
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# For multi-platform builds | |
# https://github.com/docker/build-push-action/blob/master/docs/advanced/multi-platform.md | |
- uses: docker/setup-qemu-action@v1 | |
- uses: docker/setup-buildx-action@v1 | |
- name: Initialize | |
id: init | |
run: | | |
# Determine whether to push to Docker Hub based on the event type | |
case "${{ github.event_name }}" in | |
push) | |
DOCKER_PUSH=true ;; | |
*) | |
DOCKER_PUSH=false ;; | |
esac | |
# Map git ref branch or tag name to Docker tag version | |
case "${{ github.ref }}" in | |
# Do not push upstream branches and tags to Docker Hub | |
refs/heads/upstream/*|refs/tags/upstream/*) | |
DOCKER_PUSH=false ;; | |
# Do not push pull request branches | |
refs/pulls/*) | |
DOCKER_PUSH=false ;; | |
esac | |
echo ::set-output name=docker_push::$DOCKER_PUSH | |
echo ::set-output name=docker_repo::whoi/$(basename "${{ github.repository }}" | tr A-Z a-z) | |
echo ::set-output name=docker_platforms::linux/amd64,linux/arm64 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ steps.init.outputs.docker_repo }} | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=ref,event=branch | |
type=ref,event=tag | |
type=ref,event=pr | |
type=sha | |
- name: Log into registry | |
if: steps.init.outputs.docker_push == 'true' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USER }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
# Enable Docker layer caching in the GitHub Actions cache. | |
# | |
# https://evilmartians.com/chronicles/build-images-on-github-actions-with-docker-layer-caching | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-multi-buildx-${{ github.sha }} | |
restore-keys: ${{ runner.os }}-multi-buildx | |
- name: Build the Docker image for native | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# These are still used by the /version API | |
build-args: | | |
GIT_SOURCE=${{ steps.init.outputs.git_source }} | |
GIT_REVISION=${{ steps.init.outputs.git_revision }} | |
cache-from: | | |
type=local,src=/tmp/.buildx-cache | |
type=registry,ref=${{ steps.init.outputs.docker_repo }}:buildcache | |
cache-to: | | |
type=local,dest=/tmp/.buildx-cache-new,mode=max | |
- name: Tag latest for CI testing | |
run: | | |
docker tag \ | |
${{ fromJSON(steps.meta.outputs.json).tags[0] }} \ | |
${{ steps.init.outputs.docker_repo }} | |
- name: Run test suite | |
run: docker compose run sealog-server npm run start-test | |
- name: Run server and Postman tests | |
run: | | |
docker compose up -d | |
sleep 10 | |
curl http://localhost:8000/sealog-server > /tmp/banner.txt | |
grep "Welcome to sealog-server\!" /tmp/banner.txt | |
# Install Newman for running Postman tests | |
npm install -g newman | |
# Run Postman tests | |
newman run "integration-tests/api_tests.postman_collection.json" | |
docker compose down | |
# Because `docker buildx build` cannot have multiple cache export targets | |
# yet, we build and push separately. | |
# | |
# During the build step (above), we update the GitHub Actions cache. Then | |
# we use this cache to rebuild, pushing both the image and the cache up to | |
# the registry. | |
- name: Push | |
if: steps.init.outputs.docker_push == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
platforms: ${{ steps.init.outputs.docker_platforms }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# These are still used by the /version API | |
build-args: | | |
GIT_SOURCE=${{ steps.init.outputs.git_source }} | |
GIT_REVISION=${{ steps.init.outputs.git_revision }} | |
cache-from: | | |
type=local,src=/tmp/.buildx-cache-new | |
cache-to: | | |
type=registry,ref=${{ steps.init.outputs.docker_repo }}:buildcache,mode=max | |
- name: Update cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |