Skip to content

Commit 49fd62d

Browse files
chore: Build Chat container in CI (botpress#14888)
1 parent 17d2249 commit 49fd62d

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Docker Build
2+
description: 'Build and push a Docker image to the registry'
3+
4+
inputs:
5+
repository:
6+
description: 'The name of the repository to build'
7+
required: true
8+
dockerfile:
9+
description: 'The name of the Dockerfile to build'
10+
required: true
11+
push:
12+
description: 'Whether to push the image to the registry'
13+
required: false
14+
default: false
15+
minify:
16+
description: 'Whether to minify the build'
17+
required: false
18+
default: true
19+
tag:
20+
description: 'Optional Docker tag'
21+
required: false
22+
default: ''
23+
depot-project:
24+
description: 'Depot project ID (required if no depot.json; get it from depot.dev)'
25+
required: false
26+
default: ''
27+
28+
runs:
29+
using: 'composite'
30+
steps:
31+
- uses: aws-actions/configure-aws-credentials@v3
32+
with:
33+
role-session-name: container_pusher
34+
role-to-assume: arn:aws:iam::986677156374:role/actions/build/container_pusher
35+
aws-region: us-east-1
36+
37+
- uses: aws-actions/amazon-ecr-login@v1
38+
id: ecr
39+
with:
40+
mask-password: true
41+
42+
- uses: docker/metadata-action@v4
43+
id: meta
44+
with:
45+
images: ${{ steps.ecr.outputs.registry }}/${{ inputs.repository }}
46+
flavor: |
47+
latest=false
48+
tags: |
49+
type=raw,enable=${{ inputs.tag != '' }},value=${{ inputs.tag }}
50+
type=semver,pattern={{version}}
51+
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags') }},prefix=,format=long
52+
53+
- name: Set BUILD_DATE
54+
id: meta_date
55+
shell: bash
56+
run: |
57+
export TZ=America/Toronto
58+
echo "timestamp=$(date +"%Y-%m-%d %H:%M:%S")" >> "$GITHUB_OUTPUT"
59+
60+
- name: Create ECR Registry
61+
shell: bash
62+
env:
63+
ECR_REPOSITORY: ${{ inputs.repository }}
64+
ECR_REGISTRY: ${{ steps.ecr.outputs.registry }}
65+
run: |
66+
aws --version
67+
aws ecr create-repository --repository-name $ECR_REPOSITORY || true
68+
aws ssm get-parameter --name '/cloud/container-registry/ecr-policy-document' --query 'Parameter.Value' | jq -r > repository-policy.json
69+
aws ecr set-repository-policy --repository-name $ECR_REPOSITORY --policy-text file://repository-policy.json &> /dev/null
70+
71+
- name: Set up Depot CLI
72+
uses: depot/setup-action@v1
73+
74+
- uses: depot/build-push-action@v1
75+
with:
76+
project: ${{ inputs.depot-project }}
77+
build-args: |
78+
MINIFY=${{ inputs.minify }}
79+
DOCKER_TAG=${{ inputs.tag }}
80+
BUILD_DATE=${{ steps.meta_date.outputs.timestamp }}
81+
file: ${{ inputs.dockerfile }}
82+
context: .
83+
push: ${{ inputs.push }}
84+
tags: ${{ steps.meta.outputs.tags }}
85+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/docker-chat.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build and push Chat Integration Docker
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- 'integrations/chat/**'
9+
- 'packages/sdk/**'
10+
11+
workflow_dispatch: {}
12+
13+
permissions:
14+
id-token: write
15+
contents: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}
19+
cancel-in-progress: false
20+
21+
jobs:
22+
docker-chat:
23+
runs-on: depot-ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Setup # FIXME: This should not be necessary, as the Dockerfile should be self-contained
27+
uses: ./.github/actions/setup
28+
with:
29+
extra_filters: '-F @botpresshub/chat'
30+
- uses: ./.github/actions/docker-build
31+
with:
32+
repository: chat-integration
33+
dockerfile: ./integrations/chat/Dockerfile
34+
push: ${{ github.event_name == 'workflow_dispatch' }}
35+
depot-project: ${{ secrets.DEPOT_PROJECT_ID }}

0 commit comments

Comments
 (0)