Skip to content

Commit e7f13f1

Browse files
Update the method of docker image upload (#511)
1 parent 00e2fdf commit e7f13f1

File tree

1 file changed

+30
-124
lines changed

1 file changed

+30
-124
lines changed

.github/workflows/image.yml

Lines changed: 30 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -8,62 +8,13 @@ on:
88
- release/**
99

1010
jobs:
11-
build-pr:
12-
name: build-pr-${{ matrix.platform }}
13-
if: ${{ github.repository_owner == 'getsentry' && github.event_name == 'pull_request' }}
14-
15-
permissions:
16-
contents: read
17-
packages: read
18-
19-
strategy:
20-
matrix:
21-
include:
22-
- os: ubuntu-24.04
23-
platform: amd64
24-
- os: ubuntu-24.04-arm
25-
platform: arm64
26-
27-
runs-on: ${{ matrix.os }}
28-
steps:
29-
- uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v3
30-
31-
- name: Set up Docker Buildx
32-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
33-
34-
- name: Set up Python
35-
uses: actions/setup-python@v6
36-
with:
37-
python-version: "3.13"
38-
39-
- name: Install uv
40-
uses: astral-sh/setup-uv@v7
41-
with:
42-
enable-cache: true
43-
cache-dependency-glob: pyproject.toml
44-
45-
- name: Install dependencies
46-
run: make install-dev
47-
48-
- name: Build package
49-
run: make build
50-
51-
- name: Build image
52-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.8.10
53-
with:
54-
context: .
55-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache-${{ matrix.platform }}
56-
cache-to:
57-
platforms: linux/${{ matrix.platform }}
58-
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}-${{ matrix.platform }}
59-
push: false
60-
61-
build-main-or-release:
11+
build-multiplatform:
6212
name: build-${{ matrix.platform }}
6313
if: |
64-
github.repository_owner == 'getsentry'
65-
&& github.event_name == 'push'
66-
&& (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || startsWith(github.ref, 'refs/heads/release/'))
14+
github.repository_owner == 'getsentry' && (
15+
github.event_name == 'pull_request' ||
16+
(github.event_name == 'push' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || startsWith(github.ref, 'refs/heads/release/')))
17+
)
6718
6819
permissions:
6920
contents: read
@@ -79,70 +30,23 @@ jobs:
7930

8031
runs-on: ${{ matrix.os }}
8132
steps:
82-
- uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v3
33+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
8334

84-
- name: Set up Docker Buildx
85-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
86-
87-
- name: Login to GHCR
88-
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
35+
- name: Build and push to ghcr.io
36+
if: ${{ github.actor != 'dependabot[bot]' && (github.event_name == 'push' || !github.event.pull_request.head.repo.fork) }}
37+
uses: getsentry/action-build-and-push-images@b172ab61a5f7eabd58bd42ce231b517e79947c01
8938
with:
90-
registry: ghcr.io
91-
username: ${{ github.actor }}
92-
password: ${{ secrets.GITHUB_TOKEN }}
93-
94-
- name: Extract metadata for image
95-
id: meta
96-
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5
97-
with:
98-
images: |
99-
ghcr.io/${{ github.repository }}
100-
tags: |
101-
type=sha,prefix=,format=long,suffix=-${{ matrix.platform }}
102-
labels: |
103-
org.opencontainers.image.title=${{ github.event.repository.name }}
104-
org.opencontainers.image.description=${{ github.event.repository.description }}
105-
org.opencontainers.image.vendor="Sentry"
106-
org.opencontainers.image.revision=${{ github.sha }}
107-
org.opencontainers.image.version=${{ github.sha }}
108-
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
109-
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
110-
111-
- name: Set up Python
112-
uses: actions/setup-python@v6
113-
with:
114-
python-version: "3.13"
115-
116-
- name: Install uv
117-
uses: astral-sh/setup-uv@v7
118-
with:
119-
enable-cache: true
120-
cache-dependency-glob: pyproject.toml
121-
122-
- name: Install dependencies
123-
run: make install-dev
124-
125-
- name: Build package
126-
run: make build
127-
128-
- name: Build image & Push
129-
id: build_push
130-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.8.10
131-
with:
132-
context: .
133-
tags: ${{ steps.meta.outputs.tags }}
134-
labels: ${{ steps.meta.outputs.labels }}
39+
image_name: launchpad
13540
platforms: linux/${{ matrix.platform }}
136-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache-${{ matrix.platform }}
137-
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache-${{ matrix.platform }},mode=max
138-
annotations: ${{ steps.meta.outputs.annotations }}
139-
provenance: mode=max
140-
sbom: true
141-
push: true
41+
dockerfile_path: "./Dockerfile"
42+
tag_suffix: -${{ matrix.platform }}
43+
ghcr: true
44+
tag_nightly: true
45+
tag_latest: true
14246

14347
create-manifest:
14448
name: Create multi-platform manifest
145-
needs: build-main-or-release
49+
needs: build-multiplatform
14650
if: |
14751
github.repository_owner == 'getsentry'
14852
&& github.event_name == 'push'
@@ -154,18 +58,20 @@ jobs:
15458

15559
runs-on: ubuntu-latest
15660
steps:
157-
- uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v3
61+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
15862

159-
- name: Login to GHCR
160-
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
161-
with:
162-
registry: ghcr.io
163-
username: ${{ github.actor }}
164-
password: ${{ secrets.GITHUB_TOKEN }}
63+
- name: Docker Login
64+
run: docker login --username '${{ github.actor }}' --password-stdin ghcr.io <<< "$GHCR_TOKEN"
65+
env:
66+
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Set up Docker Buildx
69+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
16570

166-
- name: Create and push multi-platform manifest
71+
- name: Create multiplatform manifests
16772
run: |
168-
./scripts/create-manifest.sh \
169-
"${{ github.repository }}" \
170-
"${{ github.sha }}" \
171-
"${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}"
73+
docker buildx imagetools create \
74+
--tag ghcr.io/getsentry/launchpad:${{ github.sha }} \
75+
--tag ghcr.io/getsentry/launchpad:nightly \
76+
ghcr.io/getsentry/launchpad:${{ github.sha }}-amd64 \
77+
ghcr.io/getsentry/launchpad:${{ github.sha }}-arm64

0 commit comments

Comments
 (0)