Skip to content

Merge pull request #12 from iIIusi0n/dev #17

Merge pull request #12 from iIIusi0n/dev

Merge pull request #12 from iIIusi0n/dev #17

name: Build and push Docker images
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
image:
- api-gateway
- chatbot
- instance-service
- instance-streaming-service
- mailer
- project-service
- user-service
- web
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Docker
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: repo_name
name: Prepare image tag path
run: echo "LOWER_GITHUB_REPOSITORY=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
env:
GITHUB_REPOSITORY: ${{ github.repository }}
- name: Build and push ${{ matrix.image }}
run: |
if [ "${{ matrix.image }}" = "web" ]; then
docker build -t ghcr.io/${{ steps.repo_name.outputs.LOWER_GITHUB_REPOSITORY }}/${{ matrix.image }}:latest -f web/Dockerfile .
else
docker build -t ghcr.io/${{ steps.repo_name.outputs.LOWER_GITHUB_REPOSITORY }}/${{ matrix.image }}:latest -f cmd/${{ matrix.image }}/Dockerfile .
fi
docker push ghcr.io/${{ steps.repo_name.outputs.LOWER_GITHUB_REPOSITORY }}/${{ matrix.image }}:latest