Files
MilkyShots/.gitea/workflows/build-and-push.yml
T

53 lines
1.4 KiB
YAML

name: Build and Push Containers
on:
push:
branches:
- master
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.2.3)'
required: true
default: 'manual'
jobs:
build-and-push:
strategy:
matrix:
service: [lactose, milkstream]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ gitea.server_url }}
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Determine version tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
else
echo "VERSION=${{ gitea.ref_name }}" >> $GITHUB_ENV
fi
- name: Build and push ${{ matrix.service }}
uses: docker/build-push-action@v5
with:
context: .
file: ./${{ matrix.service }}/Dockerfile
push: true
tags: |
${{ gitea.server_url }}/${{ gitea.repository }}/${{ matrix.service }}:${{ env.VERSION }}
${{ gitea.server_url }}/${{ gitea.repository }}/${{ matrix.service }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max