name: Publish Tactical Docker Images
on:
  push:
    tags:
      - "v*.*.*"
jobs:
  docker:
    name: Build and Push Docker Images
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@v2
        
      - name: Get Github Tag
        id: prep
        run: |
          echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
        
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
        
      - name: Login to DockerHub
        uses: docker/login-action@v1 
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
        
      - name: Build and Push Tactical Image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          pull: true
          file: ./docker/containers/tactical/dockerfile
          platforms: linux/amd64
          tags: tacticalrmm/tactical:${{ steps.prep.outputs.version }},tacticalrmm/tactical:latest
          
      - name: Build and Push Tactical MeshCentral Image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          pull: true
          file: ./docker/containers/tactical-meshcentral/dockerfile
          platforms: linux/amd64
          tags: tacticalrmm/tactical-meshcentral:${{ steps.prep.outputs.version }},tacticalrmm/tactical-meshcentral:latest
          
      - name: Build and Push Tactical NATS Image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          pull: true
          file: ./docker/containers/tactical-nats/dockerfile
          platforms: linux/amd64
          tags: tacticalrmm/tactical-nats:${{ steps.prep.outputs.version }},tacticalrmm/tactical-nats:latest
          
      - name: Build and Push Tactical Frontend Image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          pull: true
          file: ./docker/containers/tactical-frontend/dockerfile
          platforms: linux/amd64
          tags: tacticalrmm/tactical-frontend:${{ steps.prep.outputs.version }},tacticalrmm/tactical-frontend:latest
          
      - name: Build and Push Tactical Nginx Image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          pull: true
          file: ./docker/containers/tactical-nginx/dockerfile
          platforms: linux/amd64
          tags: tacticalrmm/tactical-nginx:${{ steps.prep.outputs.version }},tacticalrmm/tactical-nginx:latest
