This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
73 lines (60 loc) · 2.37 KB
/
ci.yaml
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
name: Model Runner-Build, Test & Publish Docker
on:
push:
paths:
- 'packages/model-runner/**'
- 'packages/api/**'
env:
IMAGE_NAME: model-runner
jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/model-runner
steps:
- uses: actions/checkout@v2
- name: Log into registry for Docker images
run: echo "${{ secrets.SERVICE_USER_PAT }}" | docker login docker.pkg.github.com -u ${{ secrets.SERVICE_USER }} --password-stdin
- name: Run tests
run: docker-compose build test
publish:
needs: test
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/model-runner
strategy:
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Log into registry for Docker images
run: echo "${{ secrets.SERVICE_USER_PAT }}" | docker login docker.pkg.github.com -u ${{ secrets.SERVICE_USER }} --password-stdin
- name: Build image
run: docker-compose build release
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push image (Local)
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix (refs/heads/ or refs/tags/) from version
# but keep the rest of the ref. Replaces / with - to make the package name valid.
# Do not attempt to obtain the version number from vx.y.z tags:
# this is handled by the publish_version workflow.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,refs/\(heads\|tags\)/\(.*\),\2,' | tr '/' '-')
# Always tag with git sha or version tag
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
# Use Docker `latest` tag convention for master.
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION