constellation/.github/templates/micro-service-image.yml.template

55 lines
1.5 KiB
Plaintext
Raw Normal View History

name: Build and Upload {{ micro-service }} image
env:
REGISTRY: ghcr.io
IMAGE_NAME: {{ micro-service }}
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "{{ micro-service }}/**"
- "internal/{{ micro-service-dependency-1 }}/**"
- "internal/{{ micro-service-dependency-2 }}/**"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
- name: Set up Docker Buildx
id: docker-setup
uses: docker/setup-buildx-action@v1
- name: Log in to the Container registry
id: docker-login
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push constellation-{{ micro-service }} container image
id: build-constellation-{{ micro-service }}
uses: docker/build-push-action@v2
with:
context: .
file: {{ micro-service }}/Dockerfile
target: release
push: true
tags: ${{ steps.meta.outputs.tags }}