Skip to content

Commit 9807d69

Browse files
committed
fix(#33711): cross-publish docker images to ghcr.io
Signed-off-by: Allen Conlon <[email protected]>
1 parent 8ca51ab commit 9807d69

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

.github/workflows/release-nightly.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ jobs:
5959
aws s3 sync dist/release s3://${{ secrets.AWS_S3_BUCKET }}/gitea/${{ steps.clean_name.outputs.branch }} --no-progress
6060
nightly-docker-rootful:
6161
runs-on: namespace-profile-gitea-release-docker
62+
permissions:
63+
packages: write # to publish to ghcr.io
6264
steps:
6365
- uses: actions/checkout@v4
6466
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -69,6 +71,7 @@ jobs:
6971
go-version-file: go.mod
7072
check-latest: true
7173
- uses: docker/setup-qemu-action@v3
74+
- uses: oras-project/setup-oras@v1
7275
- uses: docker/setup-buildx-action@v3
7376
- name: Get cleaned branch name
7477
id: clean_name
@@ -85,6 +88,12 @@ jobs:
8588
with:
8689
username: ${{ secrets.DOCKERHUB_USERNAME }}
8790
password: ${{ secrets.DOCKERHUB_TOKEN }}
91+
- name: Login to GHCR using PAT
92+
uses: docker/login-action@v3
93+
with:
94+
registry: ghcr.io
95+
username: ${{ github.repository_owner }}
96+
password: ${{ secrets.GITHUB_TOKEN }}
8897
- name: fetch go modules
8998
run: make vendor
9099
- name: build rootful docker image
@@ -94,8 +103,14 @@ jobs:
94103
platforms: linux/amd64,linux/arm64
95104
push: true
96105
tags: gitea/gitea:${{ steps.clean_name.outputs.branch }}
106+
- name: copy rootful docker image to ghcr.io
107+
# this will also copy both the amd64 and arm64 versions at the same time
108+
run: |-
109+
oras cp --recursive docker.io/gitea/gitea:${{ steps.meta.outputs.tags }} ghcr.io/gitea/gitea:${{ steps.meta.outputs.tags }}
97110
nightly-docker-rootless:
98111
runs-on: namespace-profile-gitea-release-docker
112+
permissions:
113+
packages: write # to publish to ghcr.io
99114
steps:
100115
- uses: actions/checkout@v4
101116
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -106,6 +121,7 @@ jobs:
106121
go-version-file: go.mod
107122
check-latest: true
108123
- uses: docker/setup-qemu-action@v3
124+
- uses: oras-project/setup-oras@v1
109125
- uses: docker/setup-buildx-action@v3
110126
- name: Get cleaned branch name
111127
id: clean_name
@@ -122,6 +138,12 @@ jobs:
122138
with:
123139
username: ${{ secrets.DOCKERHUB_USERNAME }}
124140
password: ${{ secrets.DOCKERHUB_TOKEN }}
141+
- name: Login to GHCR using PAT
142+
uses: docker/login-action@v3
143+
with:
144+
registry: ghcr.io
145+
username: ${{ github.repository_owner }}
146+
password: ${{ secrets.GITHUB_TOKEN }}
125147
- name: fetch go modules
126148
run: make vendor
127149
- name: build rootless docker image
@@ -132,3 +154,7 @@ jobs:
132154
push: true
133155
file: Dockerfile.rootless
134156
tags: gitea/gitea:${{ steps.clean_name.outputs.branch }}-rootless
157+
- name: copy rootful docker image to ghcr.io
158+
# this will also copy both the amd64 and arm64 versions at the same time
159+
run: |-
160+
oras cp --recursive docker.io/gitea/gitea:${{ steps.meta.outputs.tags }} ghcr.io/gitea/gitea:${{ steps.meta.outputs.tags }}

.github/workflows/release-tag-rc.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ jobs:
6969
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
7070
docker-rootful:
7171
runs-on: namespace-profile-gitea-release-docker
72+
permissions:
73+
packages: write # to publish to ghcr.io
7274
steps:
7375
- uses: actions/checkout@v4
7476
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
7577
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
7678
- run: git fetch --unshallow --quiet --tags --force
7779
- uses: docker/setup-qemu-action@v3
7880
- uses: docker/setup-buildx-action@v3
81+
- uses: oras-project/setup-oras@v1
7982
- uses: docker/metadata-action@v5
8083
id: meta
8184
with:
@@ -90,6 +93,12 @@ jobs:
9093
with:
9194
username: ${{ secrets.DOCKERHUB_USERNAME }}
9295
password: ${{ secrets.DOCKERHUB_TOKEN }}
96+
- name: Login to GHCR using PAT
97+
uses: docker/login-action@v3
98+
with:
99+
registry: ghcr.io
100+
username: ${{ github.repository_owner }}
101+
password: ${{ secrets.GITHUB_TOKEN }}
93102
- name: build rootful docker image
94103
uses: docker/build-push-action@v5
95104
with:
@@ -98,15 +107,22 @@ jobs:
98107
push: true
99108
tags: ${{ steps.meta.outputs.tags }}
100109
labels: ${{ steps.meta.outputs.labels }}
110+
- name: copy rootful docker image to ghcr.io
111+
# this will also copy both the amd64 and arm64 versions at the same time
112+
run: |-
113+
oras cp --recursive docker.io/gitea/gitea:${{ steps.meta.outputs.tags }} ghcr.io/gitea/gitea:${{ steps.meta.outputs.tags }}
101114
docker-rootless:
102115
runs-on: namespace-profile-gitea-release-docker
116+
permissions:
117+
packages: write # to publish to ghcr.io
103118
steps:
104119
- uses: actions/checkout@v4
105120
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
106121
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
107122
- run: git fetch --unshallow --quiet --tags --force
108123
- uses: docker/setup-qemu-action@v3
109124
- uses: docker/setup-buildx-action@v3
125+
- uses: oras-project/setup-oras@v1
110126
- uses: docker/metadata-action@v5
111127
id: meta
112128
with:
@@ -123,6 +139,12 @@ jobs:
123139
with:
124140
username: ${{ secrets.DOCKERHUB_USERNAME }}
125141
password: ${{ secrets.DOCKERHUB_TOKEN }}
142+
- name: Login to GHCR using PAT
143+
uses: docker/login-action@v3
144+
with:
145+
registry: ghcr.io
146+
username: ${{ github.repository_owner }}
147+
password: ${{ secrets.GITHUB_TOKEN }}
126148
- name: build rootless docker image
127149
uses: docker/build-push-action@v5
128150
with:
@@ -132,3 +154,7 @@ jobs:
132154
file: Dockerfile.rootless
133155
tags: ${{ steps.meta.outputs.tags }}
134156
labels: ${{ steps.meta.outputs.labels }}
157+
- name: copy rootful docker image to ghcr.io
158+
# this will also copy both the amd64 and arm64 versions at the same time
159+
run: |-
160+
oras cp --recursive docker.io/gitea/gitea:${{ steps.meta.outputs.tags }} ghcr.io/gitea/gitea:${{ steps.meta.outputs.tags }}

.github/workflows/release-tag-version.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ concurrency:
1414
jobs:
1515
binary:
1616
runs-on: namespace-profile-gitea-release-binary
17+
permissions:
18+
packages: write # to publish to ghcr.io
1719
steps:
1820
- uses: actions/checkout@v4
1921
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -71,13 +73,16 @@ jobs:
7173
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
7274
docker-rootful:
7375
runs-on: namespace-profile-gitea-release-docker
76+
permissions:
77+
packages: write # to publish to ghcr.io
7478
steps:
7579
- uses: actions/checkout@v4
7680
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
7781
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
7882
- run: git fetch --unshallow --quiet --tags --force
7983
- uses: docker/setup-qemu-action@v3
8084
- uses: docker/setup-buildx-action@v3
85+
- uses: oras-project/setup-oras@v1
8186
- uses: docker/metadata-action@v5
8287
id: meta
8388
with:
@@ -96,6 +101,12 @@ jobs:
96101
with:
97102
username: ${{ secrets.DOCKERHUB_USERNAME }}
98103
password: ${{ secrets.DOCKERHUB_TOKEN }}
104+
- name: Login to GHCR using PAT
105+
uses: docker/login-action@v3
106+
with:
107+
registry: ghcr.io
108+
username: ${{ github.repository_owner }}
109+
password: ${{ secrets.GITHUB_TOKEN }}
99110
- name: build rootful docker image
100111
uses: docker/build-push-action@v5
101112
with:
@@ -104,6 +115,10 @@ jobs:
104115
push: true
105116
tags: ${{ steps.meta.outputs.tags }}
106117
labels: ${{ steps.meta.outputs.labels }}
118+
- name: copy rootful docker image to ghcr.io
119+
# this will also copy both the amd64 and arm64 versions at the same time
120+
run: |-
121+
oras cp --recursive docker.io/gitea/gitea:${{ steps.meta.outputs.tags }} ghcr.io/gitea/gitea:${{ steps.meta.outputs.tags }}
107122
docker-rootless:
108123
runs-on: namespace-profile-gitea-release-docker
109124
steps:
@@ -113,6 +128,7 @@ jobs:
113128
- run: git fetch --unshallow --quiet --tags --force
114129
- uses: docker/setup-qemu-action@v3
115130
- uses: docker/setup-buildx-action@v3
131+
- uses: oras-project/setup-oras@v1
116132
- uses: docker/metadata-action@v5
117133
id: meta
118134
with:
@@ -134,6 +150,12 @@ jobs:
134150
with:
135151
username: ${{ secrets.DOCKERHUB_USERNAME }}
136152
password: ${{ secrets.DOCKERHUB_TOKEN }}
153+
- name: Login to GHCR using PAT
154+
uses: docker/login-action@v3
155+
with:
156+
registry: ghcr.io
157+
username: ${{ github.repository_owner }}
158+
password: ${{ secrets.GITHUB_TOKEN }}
137159
- name: build rootless docker image
138160
uses: docker/build-push-action@v5
139161
with:
@@ -143,3 +165,7 @@ jobs:
143165
file: Dockerfile.rootless
144166
tags: ${{ steps.meta.outputs.tags }}
145167
labels: ${{ steps.meta.outputs.labels }}
168+
- name: copy rootful docker image to ghcr.io
169+
# this will also copy both the amd64 and arm64 versions at the same time
170+
run: |-
171+
oras cp --recursive docker.io/gitea/gitea:${{ steps.meta.outputs.tags }} ghcr.io/gitea/gitea:${{ steps.meta.outputs.tags }}

0 commit comments

Comments
 (0)