-
Notifications
You must be signed in to change notification settings - Fork 110
49 lines (42 loc) · 1.5 KB
/
gh-packages.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
name: Push Docker Images
on:
push:
branches: ['restructure', 'main']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Log in to the Container registry
id: login
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.PAT }}
- name: Build and push docker images
run: |
image_names=$(jq -r '.models[].serviceName' ./config.json)
paths=$(jq -r '.models[].modelBasePath' ./config.json)
readarray -t image_array <<< "$image_names"
readarray -t paths_array <<< "$paths"
lowercase_actor=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
for index in "${!image_array[@]}"; do
image="${image_array[index]}"
path="${paths_array[index]}"
if git diff --quiet HEAD^..HEAD -- "./${paths_array[index]::-1}"; then
echo "No changes detected in $image"
else
docker build "./$path" -t "${{ env.REGISTRY }}/$lowercase_actor/$image:latest"
docker push "${{ env.REGISTRY }}/$lowercase_actor/$image:latest"
fi
done