-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (132 loc) · 5.51 KB
/
Copy pathbuild-docker.yml
File metadata and controls
152 lines (132 loc) · 5.51 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
name: Build and Push Python Client Image
on:
push:
branches: [master]
workflow_dispatch:
concurrency:
group: build-python-client
cancel-in-progress: false
permissions:
contents: read
packages: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-22.04
- arch: arm64
platform: linux/arm64
runner: ubuntu-22.04-arm
runs-on: ${{ matrix.runner }}
steps:
- name: Record job start time
run: echo "JOB_START_MS=$(date +%s%3N)" >> "$GITHUB_ENV"
- name: Checkout repository
uses: actions/checkout@v5
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push arch-specific image
run: |
IMAGE=ghcr.io/splintercom/intercom-python-client
APP_VERSION=$(cat VERSION)
# Built natively on a runner matching each target arch (not cross-compiled via QEMU) —
# ClientPython pulls in compiled deps (aiortc, opencv) that are slow/flaky to build
# under emulation. Pushed under a per-arch tag; the publish-manifest job below combines
# both into the real published tags (latest/sha/version) as a multi-arch manifest list.
docker build \
--build-arg APP_VERSION="$APP_VERSION" \
-f Dockerfile \
-t "$IMAGE:${{ github.sha }}-${{ matrix.arch }}" \
.
docker push "$IMAGE:${{ github.sha }}-${{ matrix.arch }}"
- name: Send CI metrics to Honeycomb
if: always()
env:
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }}
JOB_STATUS: ${{ job.status }}
run: |
END_MS=$(date +%s%3N)
DURATION_MS=$((END_MS - JOB_START_MS))
COMMIT_MSG=$(git log -1 --pretty=format:%s 2>/dev/null || echo "")
curl -s -X POST "https://api.honeycomb.io/1/events/github-actions" \
-H "X-Honeycomb-Team: $HONEYCOMB_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Honeycomb-Event-Time: $(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-d "$(jq -cn \
--arg workflow "$GITHUB_WORKFLOW" \
--arg job "build (${{ matrix.arch }})" \
--arg status "$JOB_STATUS" \
--argjson duration_ms "$DURATION_MS" \
--arg sha "$GITHUB_SHA" \
--arg ref "$GITHUB_REF_NAME" \
--arg actor "$GITHUB_ACTOR" \
--arg repository "$GITHUB_REPOSITORY" \
--argjson run_id "$GITHUB_RUN_ID" \
--argjson run_number "$GITHUB_RUN_NUMBER" \
--arg commit_message "$COMMIT_MSG" \
'{workflow: $workflow, job: $job, status: $status, duration_ms: $duration_ms,
sha: $sha, ref: $ref, actor: $actor, repository: $repository,
run_id: $run_id, run_number: $run_number, commit_message: $commit_message}')" || true
publish-manifest:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Record job start time
run: echo "JOB_START_MS=$(date +%s%3N)" >> "$GITHUB_ENV"
- name: Checkout repository
uses: actions/checkout@v5
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create and push multi-arch manifest
run: |
IMAGE=ghcr.io/splintercom/intercom-python-client
APP_VERSION=$(cat VERSION)
DOCKER_TAG=$(echo "$APP_VERSION" | tr '+' '-')
for TAG in latest "${{ github.sha }}" "$DOCKER_TAG"; do
docker buildx imagetools create \
-t "$IMAGE:$TAG" \
"$IMAGE:${{ github.sha }}-amd64" \
"$IMAGE:${{ github.sha }}-arm64"
done
- name: Send CI metrics to Honeycomb
if: always()
env:
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }}
JOB_STATUS: ${{ job.status }}
run: |
END_MS=$(date +%s%3N)
DURATION_MS=$((END_MS - JOB_START_MS))
COMMIT_MSG=$(git log -1 --pretty=format:%s 2>/dev/null || echo "")
curl -s -X POST "https://api.honeycomb.io/1/events/github-actions" \
-H "X-Honeycomb-Team: $HONEYCOMB_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Honeycomb-Event-Time: $(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-d "$(jq -cn \
--arg workflow "$GITHUB_WORKFLOW" \
--arg job "$GITHUB_JOB" \
--arg status "$JOB_STATUS" \
--argjson duration_ms "$DURATION_MS" \
--arg sha "$GITHUB_SHA" \
--arg ref "$GITHUB_REF_NAME" \
--arg actor "$GITHUB_ACTOR" \
--arg repository "$GITHUB_REPOSITORY" \
--argjson run_id "$GITHUB_RUN_ID" \
--argjson run_number "$GITHUB_RUN_NUMBER" \
--arg commit_message "$COMMIT_MSG" \
'{workflow: $workflow, job: $job, status: $status, duration_ms: $duration_ms,
sha: $sha, ref: $ref, actor: $actor, repository: $repository,
run_id: $run_id, run_number: $run_number, commit_message: $commit_message}')" || true