-
Notifications
You must be signed in to change notification settings - Fork 261
65 lines (59 loc) · 2.07 KB
/
build.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
name: "Build and Push"
on:
push:
branches:
- master
pull_request:
jobs:
build-image:
name: Build image
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
# Allow list of models
include:
- backend_dir_name: segment_anything_model
backend_tag_name: sam-v0
- backend_dir_name: llm_interactive
backend_tag_name: llm-v7
env:
IMAGE_NAME: heartexlabs/label-studio-ml-backend
examples_dir: label_studio_ml/examples
backend_dir_name: ${{ matrix.backend_dir_name }}
backend_tag_name: ${{ matrix.backend_tag_name }}
steps:
- uses: actions/checkout@v3
with:
ref: "${{ env.GITHUB_SHA }}"
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Check for Changes in Directory
id: check_changes
shell: bash
run: |
changes=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- "${{ env.examples_dir }}/${{ env.backend_dir_name }}" || true)
if [ -z "$changes" ]; then
echo "No changes in directory ${{ matrix.dir }}. Exiting job."
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "Changes detected in directory ${{ matrix.dir }}."
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Login to DockerHub
if: ${{ steps.check_changes.outputs.skip != 'true' && !github.event.pull_request.head.repo.fork }}
uses: docker/[email protected]
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image
if: steps.check_changes.outputs.skip != 'true'
uses: docker/[email protected]
id: docker_build_and_push
with:
context: ${{ env.examples_dir }}/${{ env.backend_dir_name }}
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.backend_tag_name }}
cache-from: type=gha
cache-to: type=gha,mode=max