Skip to content

feat: better AI cloud model #18

feat: better AI cloud model

feat: better AI cloud model #18

Workflow file for this run

name: Build and Publish Docker Images
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
OWNER: ${{ github.repository_owner }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set version
id: set-version
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION=latest
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Build all images in parallel
run: |
docker compose -f docker-compose.build.yaml build --parallel
- name: Tag and push images
run: |
# Get all service names from docker-compose.build.yaml
SERVICES=$(grep -E "^ [a-zA-Z0-9_-]+:" docker-compose.build.yaml | sed 's/://g' | awk '{print $1}')
# Tag and push each image
for SERVICE in $SERVICES; do
# Skip empty lines
[ -z "$SERVICE" ] && continue
# Get the image name from docker-compose.build.yaml
IMAGE_NAME=$(grep -A5 " $SERVICE:" docker-compose.build.yaml | grep "image:" | awk '{print $2}')
# Skip if no image name found
[ -z "$IMAGE_NAME" ] && continue
echo "Processing $SERVICE with image $IMAGE_NAME"
# Tag with version and SHA
GHCR_IMAGE="${REGISTRY}/${OWNER}/bashbuddy-${SERVICE}"
SHA_TAG=$(echo ${{ github.sha }} | cut -c1-7)
docker tag $IMAGE_NAME $GHCR_IMAGE:$VERSION
docker tag $IMAGE_NAME $GHCR_IMAGE:$SHA_TAG
# Push if not a PR
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
docker push $GHCR_IMAGE:$VERSION
docker push $GHCR_IMAGE:$SHA_TAG
echo "Pushed $GHCR_IMAGE:$VERSION and $GHCR_IMAGE:$SHA_TAG"
else
echo "Skipping push for PR (would have pushed $GHCR_IMAGE:$VERSION and $GHCR_IMAGE:$SHA_TAG)"
fi
done