---
name: Docker Image CI

on:
  release:
    types: [published]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Login to Docker Hub
      uses: docker/login-action@v3
      with:
        username: ${{ secrets['DOCKERHUB_USERNAME'] }}
        password: ${{ secrets['DOCKERHUB_TOKEN'] }}
    - name: Extract metadata (tags, labels) for Docker
      id: meta
      uses: docker/metadata-action@v5
      with:
        images: teampass/teampass
    - name: Build and push Docker image
      uses: docker/build-push-action@v5
      with:
        context: .
        push: true
        tags: ${{ github['ref_name'] }}
        labels: ${{ steps['meta']['outputs']['labels'] }}
