name: Deploy Docker Image to Heroku

on:
  workflow_dispatch:
    inputs:
      appName:
        description: 'Heroku App Name'
        required: true
        type: string
      imageName:
        description: 'Docker Image Name'
        required: true
        type: string
      imageTag:
        description: 'Docker Image Tag'
        required: true
        type: string
        default: 'latest'

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Login
        env:
          HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
        run: heroku container:login

      - name: Push
        env:
          HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
        run: heroku container:push ${{ inputs.imageName }} -a ${{ inputs.appName }} --recursive --arg BASE_TAG=${{ inputs.imageTag }}

      - name: Release
        env:
          HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
        run: heroku container:release ${{ inputs.imageName }} -a ${{ inputs.appName }}
