loomio/loomio

View on GitHub
.github/workflows/docker_image.yml

Summary

Maintainability
Test Coverage
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Publish Docker image

on:
  push:
  release:
    types: [published]

jobs:
  push_to_registry:
    name: Push Docker image to Docker Hub
    runs-on: ubuntu-latest
    env:
      HAVESECRET: ${{ secrets.DOCKER_USERNAME }}
    steps:
      - name: Check out the repo
        uses: actions/checkout@v3
        if: env.HAVESECRET != null

      - name: Log in to Docker Hub
        uses: docker/login-action@v2
        if: env.HAVESECRET != null
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@v4
        if: env.HAVESECRET != null
        with:
          images: loomio/loomio

      - name: Build and push Docker image
        uses: docker/build-push-action@v4
        if: env.HAVESECRET != null
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}