diff --git a/.github/actions/deploy-integrations-staging/action.yml b/.github/actions/deploy-integrations-staging/action.yml new file mode 100644 index 00000000..c0166292 --- /dev/null +++ b/.github/actions/deploy-integrations-staging/action.yml @@ -0,0 +1,77 @@ +name: Deploy Integrations to Staging +description: Deploys integrations to Botpress staging environment + +inputs: + extra_filter: + description: 'Pnpm additional filters to select integrations to deploy' + required: false + default: '' + force: + description: 'Force re-deploying integrations' + default: 'false' + required: false + dry_run: + description: 'Ask the backend to perform validation without actually deploying' + default: 'false' + required: false + +runs: + using: 'composite' + steps: + - name: Install retry-cli + shell: bash + run: pnpm add -g retry-cli + - name: Deploy Integrations to Staging + shell: bash + run: | + api_url="https://api.botpress.dev" + + echo "### Logging in to $api_url ###" + pnpm bp login --api-url $api_url --workspaceId "${{ env.BP_WORKSPACEID_STAGING }}" --token "${{ env.ERMEK_STAGING_PAT }}" + + redeploy=${{ inputs.force == 'true' && 1 || 0 }} + dryrun="${{ inputs.dry_run == 'true' && '--dryRun' || '' }}" + is_dry_run=${{ inputs.dry_run == 'true' && 1 || 0 }} + + # Get all integration directories + integration_dirs=$(find integrations -maxdepth 1 -type d -not -path integrations) + + for integration_path in $integration_dirs; do + integration=$(basename $integration_path) + + # Skip if not a valid integration directory + if [ ! -f "$integration_path/package.json" ] || [ ! -f "$integration_path/integration.definition.ts" ]; then + echo "Skipping $integration (not a valid integration)" + continue + fi + + # Apply extra filter if specified + if [ -n "${{ inputs.extra_filter }}" ]; then + if [[ ! "$integration" == *"${{ inputs.extra_filter }}"* ]]; then + echo "Skipping $integration (filtered out)" + continue + fi + fi + + # Check if integration exists using the existing script + exists=$(./.github/scripts/integration-exists.sh $integration) + + base_command="pnpm bp deploy -v -y --noBuild --public --allowDeprecated $dryrun" + + if [ $exists -eq 0 ]; then + echo -e "\nDeploying integration: ### $integration ###\n" + cd $integration_path + retry -n 2 -- $base_command + cd - > /dev/null + elif [ $redeploy -eq 1 ]; then + echo -e "\nRe-deploying integration: ### $integration ###\n" + cd $integration_path + retry -n 2 -- $base_command + cd - > /dev/null + else + echo -e "\nSkipping integration: ### $integration ###\n" + fi + done + env: + ERMEK_STAGING_PAT: ${{ env.ERMEK_STAGING_PAT }} + BP_WORKSPACEID_STAGING: ${{ env.BP_WORKSPACEID_STAGING }} \ No newline at end of file diff --git a/.github/workflows/deploy-integrations-staging.yml b/.github/workflows/deploy-integrations-staging.yml new file mode 100644 index 00000000..d23b015c --- /dev/null +++ b/.github/workflows/deploy-integrations-staging.yml @@ -0,0 +1,56 @@ +name: Deploy Integrations to Staging + +on: + push: + branches: + - master + paths: + - 'integrations/**' + + pull_request: + paths: + - 'integrations/**' + + workflow_dispatch: + inputs: + force: + description: 'Force re-deploying integrations' + type: boolean + required: false + default: false + extra_filter: + description: 'Filter integrations to deploy (partial name match)' + type: string + required: false + default: '' + +permissions: + contents: read + +jobs: + deploy-staging: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup dependencies + uses: ./.github/actions/setup + + - name: Get changed integrations + id: changed-integrations + uses: tj-actions/changed-files@v46 + with: + files: 'integrations/**' + dir_names: true + dir_names_max_depth: 2 + + - name: Deploy Integrations to Staging + uses: ./.github/actions/deploy-integrations-staging + with: + force: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.force == 'true' || false }} + extra_filter: ${{ github.event.inputs.extra_filter || '' }} + env: + ERMEK_STAGING_PAT: ${{ secrets.ERMEK_STAGING_PAT }} + BP_WORKSPACEID_STAGING: ${{ secrets.BP_WORKSPACEID_STAGING }} \ No newline at end of file diff --git a/integrations/brevo-hitl/integration.definition.ts b/integrations/brevo-hitl/integration.definition.ts index e44ca211..5fa6a448 100644 --- a/integrations/brevo-hitl/integration.definition.ts +++ b/integrations/brevo-hitl/integration.definition.ts @@ -6,6 +6,7 @@ import { events, configuration, channels as baseChannels, states, user } from '. export default new IntegrationDefinition({ name: 'plus/brevo-hitl', title: 'Brevo HITL', + // Test deployment trigger version: '1.0.0', readme: 'hub.md', description: 'Brevo HITL Integration',