Update generate.sh #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |