forked from opea-project/GenAIComps
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (60 loc) · 2.16 KB
/
_get-image-list.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
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
name: Get Image List
permissions: read-all
on:
workflow_call:
inputs:
services:
default: ""
required: false
type: string
images:
default: ""
required: false
type: string
mode:
default: "CD"
required: false
type: string
outputs:
matrix:
description: "Image List"
value: ${{ jobs.get-image-list.outputs.matrix }}
jobs:
get-image-list:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
steps:
- name: Checkout out Repo
uses: actions/checkout@v4
- name: Set Matrix
id: get-matrix
run: |
image_list=[]
if [[ ! -z "${{ inputs.services }}" ]]; then
pip install yq
services=($(echo ${{ inputs.services }} | tr ',' ' '))
for service in ${services[@]}
do
if [[ "${{ inputs.mode }}" == "CD" ]]; then
docker_compose_yml=${{ github.workspace }}/.github/workflows/docker/compose/${service}-compose-cd.yaml
else
docker_compose_yml=${{ github.workspace }}/.github/workflows/docker/compose/${service}-compose.yaml
fi
if [ -f "$docker_compose_yml" ]; then
images=$(cat $docker_compose_yml | yq -r '.[]' | jq 'keys' | jq -c '.')
image_list=$(echo ${image_list} | jq -s '.[0] + .[1] | unique' - <(echo ${images}))
fi
done
fi
if [[ ! -z "${{ inputs.images }}" ]]; then
images=($(echo ${{ inputs.images }} | tr ',' ' '))
input_image_list=$(printf '%s\n' "${images[@]}" | sort -u | jq -R '.' | jq -sc '.')
image_list=$(echo ${image_list} | jq -s '.[0] + .[1] | unique' - <(echo ${input_image_list}))
fi
echo "print image list..."
echo "$image_list" | jq . | jq -r '.[]'
echo "end of image list..."
echo "matrix=$(echo ${image_list} | jq -c '.')" >> $GITHUB_OUTPUT