-
Notifications
You must be signed in to change notification settings - Fork 16
209 lines (183 loc) · 6.92 KB
/
Copy pathcontainer.yml
File metadata and controls
209 lines (183 loc) · 6.92 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: Container
on:
push:
env:
ECR_REGION: us-west-2
AWS_ACCOUNT_ID: "850406765696"
jobs:
build:
name: Build ${{ matrix.arch }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: arm-4core-linux-ubuntu24.04
permissions:
contents: read
packages: write
id-token: write # Required for OIDC authentication with AWS
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: .
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1
with:
role-to-assume: arn:aws:iam::850406765696:role/lading-ci-sccache-oidc
aws-region: us-west-2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Log in to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
id: meta
with:
images: ghcr.io/datadog/lading
flavor: |
suffix=-${{ matrix.arch }}
latest=false
tags: |
type=semver,pattern={{version}},event=tag
type=sha,format=long
- name: Build and push to GHCR
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
file: Dockerfile
tags: ${{ steps.meta.outputs.tags }}
push: true
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/datadog/lading:cache-${{ matrix.arch }}
cache-to: type=registry,ref=ghcr.io/datadog/lading:cache-${{ matrix.arch }},mode=max
build-args: |
SCCACHE_BUCKET=lading-sccache
SCCACHE_REGION=us-west-2
secrets: |
aws_access_key_id=${{ env.AWS_ACCESS_KEY_ID }}
aws_secret_access_key=${{ env.AWS_SECRET_ACCESS_KEY }}
aws_session_token=${{ env.AWS_SESSION_TOKEN }}
copy-to-ecr:
name: Copy ${{ matrix.arch }} to ECR
needs: build
runs-on: ubuntu-24.04
strategy:
matrix:
arch: [amd64, arm64]
permissions:
contents: read
id-token: write # Required for OIDC authentication
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/lading-container-publisher-oidc
aws-region: ${{ env.ECR_REGION }}
- name: Log in to AWS ECR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.ECR_REGION }}.amazonaws.com
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Extract metadata
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
id: meta
with:
images: ghcr.io/datadog/lading
flavor: |
suffix=-${{ matrix.arch }}
latest=false
tags: |
type=semver,pattern={{version}},event=tag
type=sha,format=long
- name: Copy to ECR
run: |
ECR_REGISTRY="${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.ECR_REGION }}.amazonaws.com"
TAGS="${{ steps.meta.outputs.tags }}"
for GHCR_TAG in $TAGS; do
TAG_NAME="${GHCR_TAG##*:}"
ECR_TAG="${ECR_REGISTRY}/lading:${TAG_NAME}"
echo "Copying ${GHCR_TAG} to ${ECR_TAG}"
docker buildx imagetools create \
--tag "${ECR_TAG}" \
"${GHCR_TAG}"
done
manifest:
name: Create ${{ matrix.registry }} manifest
needs: [build, copy-to-ecr]
runs-on: ubuntu-24.04
strategy:
matrix:
registry: [ghcr, ecr]
include:
- registry: ghcr
registry_url: ghcr.io
image_name: datadog/lading
- registry: ecr
image_name: lading
permissions:
contents: read
packages: write
id-token: write # Required for OIDC authentication
steps:
- name: Log in to GitHub Container Registry
if: matrix.registry == 'ghcr'
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS credentials via OIDC
if: matrix.registry == 'ecr'
uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/lading-container-publisher-oidc
aws-region: ${{ env.ECR_REGION }}
- name: Log in to AWS ECR
if: matrix.registry == 'ecr'
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.ECR_REGION }}.amazonaws.com
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Set registry URL
id: registry
run: |
if [ "${{ matrix.registry }}" = "ghcr" ]; then
echo "url=ghcr.io" >> "$GITHUB_OUTPUT"
else
echo "url=${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.ECR_REGION }}.amazonaws.com" >> "$GITHUB_OUTPUT"
fi
- name: Extract metadata
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
id: meta
with:
images: ${{ steps.registry.outputs.url }}/${{ matrix.image_name }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}},event=tag
type=sha,format=long
- name: Create and push manifest
run: |
TAGS="${{ steps.meta.outputs.tags }}"
for TAG in $TAGS; do
echo "Creating manifest for ${TAG}"
docker buildx imagetools create \
--tag "${TAG}" \
"${TAG}-amd64" \
"${TAG}-arm64"
done