Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/actions/deploy-integrations/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ runs:
# shellcheck disable=SC2086 # SENTRY_FILTER contains multiple space-separated -F flags that must be split into individual arguments
pnpm -r --stream $SENTRY_FILTER exec sentry-cli sourcemaps upload --release="$GITHUB_SHA" --url-prefix '~' .botpress/dist
- name: Deploys Integrations
shell: bash
env:
INPUT_ENVIRONMENT: ${{ inputs.environment }}
INPUT_FORCE: ${{ inputs.force }}
Expand All @@ -74,6 +73,8 @@ runs:
CLOUD_OPS_WORKSPACE_ID: ${{ inputs.cloud_ops_workspace_id }}
SENTRY_RELEASE: ${{ github.sha }}
SENTRY_ENVIRONMENT: ${{ inputs.environment }}
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
if [ "$INPUT_ENVIRONMENT" = "staging" ]; then
api_url="https://api.botpress.dev"
Expand Down Expand Up @@ -104,12 +105,24 @@ runs:

all_filters="-F '{integrations/*}' $INPUT_EXTRA_FILTER"
list_integrations_cmd="pnpm list $all_filters --json"
integration_paths=$(eval "$list_integrations_cmd" | jq -r 'map(".path") | .[]')
integration_paths=$(eval "$list_integrations_cmd" | jq -r 'map(.path) | .[]')

for integration_path in $integration_paths; do
integration=$(basename "$integration_path")
exists=$(./.github/scripts/integration-exists.sh "$integration")

if [ "$integration" == "chat" ]; then
if [ $exists -eq 0 ] || [ $redeploy -eq 1 ]; then
echo -e "\nTriggering ECS deploy for: ### $integration ###\n"
if [ $is_dry_run -eq 0 ]; then
gh workflow run "deploy-chat-${INPUT_ENVIRONMENT}.yml" --field branchOrCommit="${GITHUB_SHA}"
fi
else
echo -e "\nSkipping integration: ### $integration ###\n"
fi
continue
fi

base_command="bp deploy -v -y --noBuild --visibility public --allowDeprecated $dryrun"

upload_sandbox_scripts=false
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/deploy-interfaces/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy Interfaces
description: Deploys interfaces

input:
inputs:
environment:
type: choice
description: 'Environment to deploy to'
Expand Down Expand Up @@ -59,7 +59,7 @@ runs:

all_filters="-F '{interfaces/*}' $INPUT_EXTRA_FILTER"
list_interfaces_cmd="pnpm list $all_filters --json"
interface_paths=$(eval "$list_interfaces_cmd" | jq -r 'map(".path") | .[]')
interface_paths=$(eval "$list_interfaces_cmd" | jq -r 'map(.path) | .[]')

for interface_path in $interface_paths; do
interface=$(basename "$interface_path")
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/deploy-plugins/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy Plugins
description: Deploys plugins

input:
inputs:
environment:
type: choice
description: 'Environment to deploy to'
Expand Down Expand Up @@ -59,7 +59,7 @@ runs:

all_filters="-F '{plugins/*}' $INPUT_EXTRA_FILTER"
list_plugins_cmd="pnpm list $all_filters --json"
plugin_paths=$(eval "$list_plugins_cmd" | jq -r 'map(".path") | .[]')
plugin_paths=$(eval "$list_plugins_cmd" | jq -r 'map(.path) | .[]')

for plugin_path in $plugin_paths; do
plugin=$(basename "$plugin_path")
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/deploy-chat-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Deploy Chat Production

on:
workflow_dispatch:
inputs:
branchOrCommit:
description: 'Branch/Commit/Tag to deploy'
required: false
type: string
default: 'master'
skipDeploy:
description: 'Skip deployment to ECS'
required: false
type: boolean
default: false
builder:
description: 'Image Builder'
required: false
type: choice
options:
- docker
- depot
default: 'depot'

permissions:
id-token: write
contents: write

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

jobs:
deploy-chat-production:
runs-on: ubuntu-latest
steps:
- uses: botpress/gh-actions/full-service-deploy@v3.3
with:
service: chat
repository: chat-integration
dockerfile: integrations/chat/Dockerfile
context: .
builder: ${{ inputs.builder || 'depot' }}
depot-project: ${{ secrets.DEPOT_PROJECT_ID }}
role-ecs-update: botpress_infra_update
skip-ecs-update: ${{ inputs.skipDeploy }}
create-tag: true
ref: ${{ inputs.branchOrCommit || github.sha }}
environment: production

update-integration-url:
needs: deploy-chat-production
if: ${{ !inputs.skipDeploy }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branchOrCommit || github.sha }}

- name: Setup
uses: ./.github/actions/setup

- name: Deploy integration with ECS URL
run: |
pnpm bp login -y \
--api-url "https://api.botpress.cloud" \
--workspaceId "${{ secrets.PRODUCTION_CLOUD_OPS_WORKSPACE_ID }}" \
--token "${{ secrets.PRODUCTION_TOKEN_CLOUD_OPS_ACCOUNT }}"

pnpm -F @botpresshub/chat -c exec -- \
bp deploy -v -y --noBuild --visibility public --allowDeprecated \
--url "http://chat.private:9271"

ping-success:
needs: [deploy-chat-production, update-integration-url]
runs-on: ubuntu-latest
steps:
- run: curl -m 10 --retry 5 ${{ secrets.CHAT_DEPLOY_PRODUCTION_PING_URL }}

ping-failure:
needs: [deploy-chat-production, update-integration-url]
if: ${{ failure() }}
runs-on: ubuntu-latest
steps:
- run: curl -m 10 --retry 5 ${{ secrets.CHAT_DEPLOY_PRODUCTION_PING_URL }}/fail
84 changes: 84 additions & 0 deletions .github/workflows/deploy-chat-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Deploy Chat Staging

on:
workflow_dispatch:
inputs:
branchOrCommit:
description: 'Branch/Commit/Tag to deploy'
required: false
type: string
default: 'master'
skipDeploy:
description: 'Skip deployment to ECS'
required: false
type: boolean
default: false
builder:
description: 'Image Builder'
required: false
type: choice
options:
- docker
- depot
default: 'depot'

permissions:
id-token: write
contents: write

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

jobs:
deploy-chat-staging:
runs-on: ubuntu-latest
steps:
- uses: botpress/gh-actions/full-service-deploy@v3.3
with:
service: chat
repository: chat-integration
dockerfile: integrations/chat/Dockerfile
context: .
builder: ${{ inputs.builder || 'depot' }}
depot-project: ${{ secrets.DEPOT_PROJECT_ID }}
role-ecs-update: botpress_infra_update
skip-ecs-update: ${{ inputs.skipDeploy }}
ref: ${{ inputs.branchOrCommit || github.sha }}
environment: staging

update-integration-url:
needs: deploy-chat-staging
if: ${{ !inputs.skipDeploy }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branchOrCommit || github.sha }}

- name: Setup
uses: ./.github/actions/setup

- name: Deploy integration with ECS URL
run: |
pnpm bp login -y \
--api-url "https://api.botpress.dev" \
--workspaceId "${{ secrets.STAGING_CLOUD_OPS_WORKSPACE_ID }}" \
--token "${{ secrets.STAGING_TOKEN_CLOUD_OPS_ACCOUNT }}"

pnpm -F @botpresshub/chat -c exec -- \
bp deploy -v -y --noBuild --visibility public --allowDeprecated \
--url "http://chat.private:9271"

ping-success:
needs: [deploy-chat-staging, update-integration-url]
runs-on: ubuntu-latest
steps:
- run: curl -m 10 --retry 5 ${{ secrets.CHAT_DEPLOY_STAGING_PING_URL }}

ping-failure:
needs: [deploy-chat-staging, update-integration-url]
if: ${{ failure() }}
runs-on: ubuntu-latest
steps:
- run: curl -m 10 --retry 5 ${{ secrets.CHAT_DEPLOY_STAGING_PING_URL }}/fail
1 change: 1 addition & 0 deletions .github/workflows/deploy-integrations-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
permissions:
id-token: write
contents: read
actions: write

jobs:
deploy-production:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-integrations-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
permissions:
id-token: write
contents: read
actions: write

jobs:
deploy-staging:
Expand Down
79 changes: 2 additions & 77 deletions .github/workflows/docker-chat.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and push Chat Integration Docker
name: Check Chat Integration Docker

on:
pull_request:
Expand All @@ -8,21 +8,6 @@ on:
- 'integrations/chat/**'
- 'packages/sdk/**'

push:
branches:
- master
paths:
- 'integrations/chat/**'
- 'packages/sdk/**'

workflow_dispatch:
inputs:
push_to_ecr:
description: 'Push image to ECR after successful tests'
required: true
type: boolean
default: true

permissions:
id-token: write
contents: read
Expand All @@ -32,55 +17,11 @@ concurrency:
cancel-in-progress: false

jobs:
build-test-push:
build-and-test:
runs-on: depot-ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup # FIXME: This should not be necessary, as the Dockerfile should be self-contained
uses: ./.github/actions/setup
with:
extra_filters: '-F @botpresshub/chat'

- uses: aws-actions/configure-aws-credentials@v3
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_to_ecr) }}
with:
role-session-name: container_pusher
role-to-assume: arn:aws:iam::986677156374:role/actions/build/container_pusher
aws-region: us-east-1

- uses: aws-actions/amazon-ecr-login@v1
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_to_ecr) }}
id: ecr
with:
mask-password: true

- uses: docker/metadata-action@v4
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_to_ecr) }}
id: meta
with:
images: ${{ steps.ecr.outputs.registry }}/chat-integration
flavor: |
latest=false
tags: |
type=sha,prefix=,format=long

- name: Set BUILD_DATE
id: meta_date
run: |
export TZ=America/Toronto
echo "timestamp=$(date +"%Y-%m-%d %H:%M:%S")" >> "$GITHUB_OUTPUT"

- name: Create ECR Registry
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_to_ecr) }}
env:
ECR_REPOSITORY: chat-integration
run: |
aws --version
aws ecr create-repository --repository-name "$ECR_REPOSITORY" || true
aws ssm get-parameter --name '/cloud/container-registry/ecr-policy-document' --query 'Parameter.Value' | jq -r '.' > repository-policy.json
aws ecr set-repository-policy --repository-name "$ECR_REPOSITORY" --policy-text file://repository-policy.json &> /dev/null

- name: Set up Depot CLI
uses: depot/setup-action@v1

Expand All @@ -90,13 +31,11 @@ jobs:
project: ${{ secrets.DEPOT_PROJECT_ID }}
build-args: |
MINIFY=true
BUILD_DATE=${{ steps.meta_date.outputs.timestamp }}
file: ./integrations/chat/Dockerfile
context: .
push: false
load: true
tags: chat-integration:test
labels: ${{ steps.meta.outputs.labels }}

- name: Start Docker container
run: |
Expand Down Expand Up @@ -148,17 +87,3 @@ jobs:
- name: Cleanup container
if: always()
run: docker rm -f chat-test || true

- name: Tag and push to ECR
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_to_ecr) }}
env:
ECR_REGISTRY: ${{ steps.ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
echo "Tagging image for ECR: $ECR_REGISTRY/chat-integration:$IMAGE_TAG"
docker tag chat-integration:test "$ECR_REGISTRY/chat-integration:$IMAGE_TAG"

echo "Pushing to ECR..."
docker push "$ECR_REGISTRY/chat-integration:$IMAGE_TAG"

echo "Successfully pushed image: $IMAGE_TAG"
Loading
Loading