Skip to content

Commit bcbe9c0

Browse files
committed
add build depot
1 parent 5f6a2da commit bcbe9c0

File tree

2 files changed

+137
-16
lines changed

2 files changed

+137
-16
lines changed

build/depot/action.yml

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

build/docker/action.yml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
name: Docker to ECR
22
description: Push Docker image to ECR
33
inputs:
4-
push:
5-
description: 'Push to registry'
6-
required: true
7-
default: 'true'
8-
repository:
9-
description: 'Repository name'
10-
required: true
4+
# Build
115
context:
126
description: 'Docker context for the build'
13-
required: true
7+
required: false
148
default: '.'
159
dockerfile:
1610
description: 'Path to Dockerfile'
11+
required: false
12+
default: 'Dockerfile'
13+
push:
14+
description: 'Whether to push the image to the registry'
1715
required: true
16+
default: 'true'
17+
tag:
18+
description: 'Optional Docker tag'
19+
required: false
1820
default: ''
21+
22+
# Custom variables
23+
sentry-auth-token:
24+
description: 'Auth token for sentry (optional)'
25+
required: false
26+
minify:
27+
description: 'Whether to minify the build'
28+
required: false
29+
default: true
30+
31+
# Deploy
32+
repository:
33+
description: 'Name of the ECR repository'
34+
required: true
1935
aws-role:
2036
description: 'AWS Role to assume'
2137
required: true
@@ -24,10 +40,6 @@ inputs:
2440
description: 'AWS Region'
2541
required: true
2642
default: us-east-1
27-
tag:
28-
description: 'Optional Docker tag'
29-
required: false
30-
default: ''
3143

3244
runs:
3345
using: 'composite'
@@ -42,6 +54,8 @@ runs:
4254

4355
- uses: aws-actions/amazon-ecr-login@v1
4456
id: ecr
57+
with:
58+
mask-password: true
4559

4660
- uses: docker/metadata-action@v4
4761
id: meta
@@ -76,13 +90,17 @@ runs:
7690
env:
7791
DOCKER_BUILDKIT: '1'
7892
with:
79-
context: ${{ inputs.context }}
93+
build-args: |
94+
SENTRY_AUTH_TOKEN=${{ inputs.sentry-auth-token }}
95+
SENTRY_ORGANIZATION_SLUG=botpress-rm
96+
SENTRY_RELEASE=${{ github.sha }}
97+
MINIFY=${{ inputs.minify }}
98+
DOCKER_TAG=${{ inputs.tag }}
99+
BUILD_DATE=${{ steps.meta_date.outputs.timestamp }}
80100
file: ${{ inputs.dockerfile }}
101+
context: ${{ inputs.context }}
81102
push: ${{ inputs.push }}
82103
cache-from: type=gha
83104
cache-to: type=gha,mode=max
84105
tags: ${{ steps.meta.outputs.tags }}
85106
labels: ${{ steps.meta.outputs.labels }}
86-
build-args: |
87-
DOCKER_TAG=${{ inputs.tag }}
88-
BUILD_DATE=${{ steps.meta_date.outputs.timestamp }}

0 commit comments

Comments
 (0)