Skip to content

Commit de1156a

Browse files
authored
ci: decouple ghcr and quay image publishing (#2004)
Decouple the push process per registry to make sure we're not blocked when quay is down
1 parent 3f3d837 commit de1156a

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

.github/workflows/release.yaml

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,6 @@ jobs:
167167
username: ${{ github.actor }}
168168
password: ${{ secrets.GITHUB_TOKEN }}
169169

170-
- name: Login to Quay.io
171-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
172-
with:
173-
registry: quay.io
174-
username: ${{ secrets.QUAY_USERNAME }}
175-
password: ${{ secrets.QUAY_PASSWORD }}
176-
177170
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
178171
with:
179172
go-version-file: "go.mod"
@@ -188,30 +181,42 @@ jobs:
188181
with:
189182
cosign-release: "v2.2.2"
190183

191-
- name: Prepare
192-
run: |
193-
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
194-
echo "REPOS"="quay.io/grafana-operator/grafana-operator" "ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
195-
196184
- name: Build and push
197185
env:
198186
IMAGE_VERSION: ${{ github.ref_name }}
187+
KO_DOCKER_REPO: "ghcr.io/${{ github.repository }}"
199188
run: |
200-
for i in ${{ env.REPOS }}
201-
do
202-
export KO_DOCKER_REPO=${i}
203-
ko build --sbom=spdx --image-refs ./image-digest-${i%.*} --bare --platform linux/arm64,linux/arm/v7,linux/amd64,linux/ppc64le -t ${IMAGE_VERSION} \
189+
ko build --sbom=spdx --image-refs ./image-digest --bare --platform linux/arm64,linux/arm/v7,linux/amd64,linux/ppc64le -t ${IMAGE_VERSION} \
204190
--image-label org.opencontainers.image.title=grafana-operator \
205191
--image-label org.opencontainers.image.description="An operator for Grafana that installs and manages Grafana instances & Dashboards & Datasources through Kubernetes/OpenShift CRs" \
206192
--image-label org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }} \
207193
--image-label org.opencontainers.image.revision=${{ github.sha }} \
208194
--image-label org.opencontainers.image.version=${IMAGE_VERSION} \
209-
--image-label org.opencontainers.image.created=${{ env.BUILD_DATE }}
210-
done
195+
--image-label org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
211196
212197
- name: Sign Image
213198
run: |
214-
for i in ${{ env.REPOS }}
215-
do
216-
cosign sign -d -y $(cat ./image-digest-${i%.*})
217-
done
199+
cosign sign -d -y $(cat ./image-digest)
200+
201+
distribute-to-quay:
202+
runs-on: ubuntu-latest
203+
needs:
204+
- image
205+
permissions:
206+
packages: read
207+
steps:
208+
- name: Copy image to quay
209+
env:
210+
IMAGE_VERSION: ${{ github.ref_name }}
211+
DOCKER_REPO: "ghcr.io/${{ github.repository }}"
212+
GHCR_USERNAME: ${{ github.actor }}
213+
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
214+
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
215+
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
216+
run: |
217+
docker run -it --rm quay.io/containers/skopeo:v1.18.0 \
218+
copy --multi-arch all \
219+
--source-creds "$GHCR_USERNAME:$GHCR_PASSWORD" \
220+
--dest-creds "$QUAY_USERNAME:$QUAY_PASSWORD" \
221+
docker://${DOCKER_REPO}:${IMAGE_VERSION} \
222+
docker://quay.io/grafana-operator/grafana-operator:${IMAGE_VERSION}

0 commit comments

Comments
 (0)