Skip to content

Update container-ci.yml #16

Update container-ci.yml

Update container-ci.yml #16

Workflow file for this run

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
list-services:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.set_services.outputs.services }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: List folder structure for services
run: |
# List all directories that match the service pattern (e.g., service folders in your repo)
directories=$(find . -maxdepth 2 -type d -name "*.API" | sed 's|^\./||')
echo "Directories found: $directories"
# Save the directories as a space-separated list in the output
echo "::set-output name=services::$(echo $directories | tr ' ' '\n')"
build-and-push:
needs: list-services
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
service: ${{ fromJson(needs.list-services.outputs.services) }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Log in to GitHub Container
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Service Lowercase
id: set_service_lowercase
run: |
service_lowercase=$(echo ${{ matrix.service }} | tr '[:upper:]' '[:lower:]')
echo "service_lowercase=$service_lowercase" >> $GITHUB_ENV
echo "::set-output name=service_lowercase::$service_lowercase"
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.service }}/${{ matrix.service }}.API/Dockerfile
push: true
tags: |
ghcr.io/${{ github.actor }}/${{ steps.set_service_lowercase.outputs.service_lowercase }}-api:latest