name: Build and Trigger Deploy

run-name: Build and trigger the deployment of ${{ inputs.LAMBDA_NAME }} Lambda for ${{ inputs.ENV_NAME }} environment

permissions:
  id-token: write
  contents: read
  issues: write

on:
  workflow_dispatch:
    inputs:
      ENV_NAME:
        description: Environment to build
        type: choice
        required: true
        default: palpatine
        options:
        - ahsoka
        - anakin
        - solo
        - vader
        - boba
        - jabba
        - rey
        - r2d2
        - palpatine
        - bb8
        - c3po
        - staging
        - production
        - production-eu
      LAMBDA_NAME:
        type: choice
        description: Lambda to build
        required: true
        options:
        - swg-lambda-fetch-profile
        - swg-lambda-compute-profile
      ENV_FILE_VERSION:
        required: false
        description: The version of .env file to deploy (example v8-ENV_VARS)

env:
  ENV_NAME: ${{ inputs.ENV_NAME }}
  AWS_REGION: us-east-1
  AWS_SECRET_REGION: 'eu-west-2'
  NEXUS_USER: svc.nexus@perimeter81.com
  NODE_VERSION: 20
  LAMBDA_NAME: ${{ inputs.LAMBDA_NAME }}
  ENV_FILE_VERSION: ${{ inputs.ENV_FILE_VERSION }}
  BUILD_NUMBER: ${{ github.run_number }}
  LAMBDA_ROOT_PATH: src
  COVERAGE_GATE: 80

jobs:
  build_and_deploy:
    runs-on: ubuntu-22.04
    environment: ${{ inputs.ENV_NAME }}
    steps:
    - name: build and trigger deploy
      uses: perimeter-81/actions/actions/lambdas/build_and_trigger_deploy@main
