-
Notifications
You must be signed in to change notification settings - Fork 3
66 lines (65 loc) · 2.37 KB
/
docker-push.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
name: push-docker-prebuilt
on:
workflow_dispatch:
push:
branches: ['main']
pull_request:
env:
LINES: 120
COLUMNS: 120
PYTEST_PLUGINS: bentoml.testing.pytest.plugin
SETUPTOOLS_USE_DISTUTILS: stdlib
BENTOML_BUNDLE_LOCAL_BUILD: True
REGISTRY: ghcr.io
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
defaults:
run:
shell: bash --noprofile --norc -exo pipefail {0}
concurrency:
group: docker-build-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
build-containerize-push:
strategy:
fail-fast: false
matrix:
tag: [cpu, gpu]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all tags and branches
- name: Setup CI
uses: ./.github/actions/setup-repo
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- id: repository
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
- name: Build and containerize
run: |
if [ "${{ matrix.tag }}" == 'gpu' ]; then
BENTOFILE='bentofile.gpu.yaml'
TAG="$(basename ${{ steps.repository.outputs.lowercase }})-gpu"
else
BENTOFILE='bentofile.yaml'
TAG="$(basename ${{ steps.repository.outputs.lowercase }})"
fi
bentoml build -f "${BENTOFILE}" && bentoml containerize "$TAG" --opt progress=plain --image-tag ${{ env.REGISTRY }}/${{ steps.repository.outputs.lowercase }}:${{ matrix.tag }}
- name: Check available images
run: docker image list
- name: Log in to the Container registry
uses: docker/login-action@40891eba8c2bcd1309b07ba8b11232f313e86779
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image to Github Container registry
if: '!github.event.repository.fork' # No need to run this actions on fork
# if: ${{ !github.event.repository.fork && github.event_name == 'push' }} # No need to run this actions on fork
run: docker push ${{ env.REGISTRY }}/${{ steps.repository.outputs.lowercase }}:${{ matrix.tag }}