name: Tag Latest Version

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'The version (ie v0.0.1) to tag as latest'
        required: true

jobs:
  tag:
    runs-on: ubuntu-latest
    steps:
    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1

    - name: Login to Docker Hub
      uses: docker/login-action@v1
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_TOKEN }}

    - name: Enable Docker CLI experimental features
      run: echo "DOCKER_CLI_EXPERIMENTAL=enabled" >> $GITHUB_ENV

    - name: Pull, Tag and Push Web Server Image
      run: |
        docker buildx imagetools create -t danswer/danswer-web-server:latest danswer/danswer-web-server:${{ github.event.inputs.version }}

    - name: Pull, Tag and Push API Server Image
      run: |
        docker buildx imagetools create -t danswer/danswer-backend:latest danswer/danswer-backend:${{ github.event.inputs.version }}
