Skip to content

ci(github): use matrix strategy for build images jobs #5

ci(github): use matrix strategy for build images jobs

ci(github): use matrix strategy for build images jobs #5

Workflow file for this run

name: Build and Push Images
on:
pull_request:
branches:
- main
- develop
push:
branches:
- feat/dockerize
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ${{ github.repository }}
jobs:
build-images:
runs-on: ubuntu-latest
strategy:
matrix:
images: ["catalogue", "voting", "recommendation", "frontend"]
context: ["catalogue", "voting", "recommendation", "frontend"]
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ matrix.images }}
tags: |
type=ref,event=pr
type=sha,prefix=pr-${{ github.event.pull_request.number }}-
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./${{ matrix.context }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max