name: Upgrade Module

on:
  workflow_dispatch:
    inputs:
      database_name:
        description: 'Database Name'
        required: true
        type: string
      module_name:
        description: 'Module Name'
        required: true
        type: string
      environment:
        description: 'Select Server'
        required: true
        type: choice
        options:
          - dev
        default: dev

jobs:
  upgrade_master:
    name: Upgrade Dev server
    runs-on: odex30-runner
    if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'dev'
    steps:
      - name: Upgrade Module
        env:
            DATABASE_NAME: ${{ github.event.inputs.database_name }}
            MODULE_NAME: ${{ github.event.inputs.module_name }}
        run: |
            chmod +x /home/${{ secrets.CLIENT_USER }}/scripts/upgrade/upgrade-module.sh
            /home/${{ secrets.CLIENT_USER }}/scripts/upgrade/upgrade-module.sh "$DATABASE_NAME" "$MODULE_NAME"
