-
Notifications
You must be signed in to change notification settings - Fork 182
187 lines (173 loc) · 6.31 KB
/
Copy pathpr-preview.yml
File metadata and controls
187 lines (173 loc) · 6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: PR Preview Build
on:
workflow_dispatch:
inputs:
pr_number:
description: 'PR number (e.g. 123)'
required: true
type: number
variant:
description: 'Dockerfile variant'
required: false
type: choice
options:
- default
- kiro
- unified
- agentcore
- antigravity
- claude
- codex
- copilot
- cursor
- devin
- gemini
- grok
- hermes
- kimi
- mimocode
- native
- opencode
- pi
default: 'default'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
resolve-pr:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
ref: ${{ steps.pr.outputs.ref }}
repo: ${{ steps.pr.outputs.repo }}
dockerfile: ${{ steps.df.outputs.file }}
suffix: ${{ steps.df.outputs.suffix }}
build_args: ${{ steps.df.outputs.build_args }}
tag_suffix: ${{ steps.df.outputs.tag_suffix }}
target: ${{ steps.df.outputs.target }}
steps:
- name: Get PR branch
id: pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ inputs.pr_number }}
run: |
PR_JSON=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}")
echo "ref=$(echo "$PR_JSON" | jq -r '.head.ref')" >> "$GITHUB_OUTPUT"
echo "repo=$(echo "$PR_JSON" | jq -r '.head.repo.full_name')" >> "$GITHUB_OUTPUT"
- name: Resolve Dockerfile
id: df
env:
VARIANT: ${{ inputs.variant }}
run: |
if [ "$VARIANT" = "default" ]; then
echo "file=Dockerfile" >> "$GITHUB_OUTPUT"
echo "suffix=" >> "$GITHUB_OUTPUT"
echo "build_args=" >> "$GITHUB_OUTPUT"
echo "tag_suffix=" >> "$GITHUB_OUTPUT"
echo "target=" >> "$GITHUB_OUTPUT"
elif [ "$VARIANT" = "kiro" ]; then
# Unified build (all platforms) tagged as :pr<N>-kiro
echo "file=Dockerfile" >> "$GITHUB_OUTPUT"
echo "suffix=" >> "$GITHUB_OUTPUT"
echo "build_args=BUILD_MODE=unified" >> "$GITHUB_OUTPUT"
echo "tag_suffix=-kiro" >> "$GITHUB_OUTPUT"
echo "target=" >> "$GITHUB_OUTPUT"
elif [ "$VARIANT" = "unified" ]; then
# Same base Dockerfile as "default", but built with BUILD_MODE=unified
# so the telegram/line/feishu/wecom/googlechat/teams gateway adapters
# (Cargo feature `unified`) are actually compiled in. The "default"
# variant builds with openab's default Cargo features only
# (discord/slack/...), which does NOT include telegram — a PR
# touching the unified gateway path needs this variant to test
# against a real webhook, not "default".
echo "file=Dockerfile" >> "$GITHUB_OUTPUT"
echo "suffix=" >> "$GITHUB_OUTPUT"
echo "build_args=BUILD_MODE=unified" >> "$GITHUB_OUTPUT"
echo "tag_suffix=" >> "$GITHUB_OUTPUT"
echo "target=" >> "$GITHUB_OUTPUT"
else
# Unified Dockerfile with --target for agent-specific variants.
# Image: ghcr.io/openabdev/openab:pr<N>-<variant>
echo "file=Dockerfile.unified" >> "$GITHUB_OUTPUT"
echo "suffix=" >> "$GITHUB_OUTPUT"
echo "build_args=" >> "$GITHUB_OUTPUT"
echo "tag_suffix=-${VARIANT}" >> "$GITHUB_OUTPUT"
echo "target=${VARIANT}" >> "$GITHUB_OUTPUT"
fi
build:
needs: resolve-pr
strategy:
matrix:
platform:
- { os: linux/amd64, runner: ubuntu-latest }
- { os: linux/arm64, runner: ubuntu-24.04-arm }
runs-on: ${{ matrix.platform.runner }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
with:
repository: ${{ needs.resolve-pr.outputs.repo }}
ref: ${{ needs.resolve-pr.outputs.ref }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: ${{ needs.resolve-pr.outputs.dockerfile }}
target: ${{ needs.resolve-pr.outputs.target || '' }}
platforms: ${{ matrix.platform.os }}
build-args: ${{ needs.resolve-pr.outputs.build_args }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ needs.resolve-pr.outputs.suffix }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=pr-${{ inputs.variant }}-${{ matrix.platform.os }}
cache-to: type=gha,scope=pr-${{ inputs.variant }}-${{ matrix.platform.os }},mode=max
- name: Export digest
env:
DIGEST: ${{ steps.build.outputs.digest }}
run: |
mkdir -p /tmp/digests
touch "/tmp/digests/${DIGEST#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.platform.runner }}
path: /tmp/digests/*
retention-days: 1
merge:
needs: [resolve-pr, build]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list
env:
SUFFIX: ${{ needs.resolve-pr.outputs.suffix }}
TAG_SUFFIX: ${{ needs.resolve-pr.outputs.tag_suffix }}
PR_NUMBER: ${{ inputs.pr_number }}
run: |
IMAGE="${REGISTRY}/${IMAGE_NAME}${SUFFIX}"
docker buildx imagetools create \
-t "${IMAGE}:pr${PR_NUMBER}${TAG_SUFFIX}" \
$(printf "${IMAGE}@sha256:%s " $(ls /tmp/digests/))