ci: fix
This commit is contained in:
parent
be9542f9e3
commit
e5d73f9b6c
|
@ -38,14 +38,15 @@ image_tag_norm() {
|
|||
# CI_COMMIT_SHORT_SHA="${CI_COMMIT_SHA:0:8}"
|
||||
CI_COMMIT_SHORT_SHA=$(printf '%s' "${CI_COMMIT_SHA}" | cut -c 1-8)
|
||||
if [ -n "${CI_COMMIT_BRANCH}" ] ; then
|
||||
CI_COMMIT_REF_SLUG="$(ref_slug "${CI_COMMIT_BRANCH}")"
|
||||
CI_COMMIT_REF_SLUG="${CI_COMMIT_BRANCH}"
|
||||
fi
|
||||
if [ -n "${CI_COMMIT_SOURCE_BRANCH}" ] ; then
|
||||
CI_COMMIT_REF_SLUG="$(ref_slug "${CI_COMMIT_SOURCE_BRANCH}")"
|
||||
CI_COMMIT_REF_SLUG="${CI_COMMIT_SOURCE_BRANCH}"
|
||||
fi
|
||||
if [ -n "${CI_COMMIT_TAG}" ] ; then
|
||||
CI_COMMIT_REF_SLUG="$(ref_slug "${CI_COMMIT_TAG}")"
|
||||
CI_COMMIT_REF_SLUG="${CI_COMMIT_TAG}"
|
||||
fi
|
||||
CI_COMMIT_REF_SLUG="$(image_tag_norm "${CI_COMMIT_REF_SLUG}")"
|
||||
|
||||
## image tag(s)
|
||||
IMAGE_TAG="${CI_COMMIT_SHORT_SHA}-b${CI_PIPELINE_NUMBER}-${CI_COMMIT_REF_SLUG}"
|
||||
|
|
40
.ci/sync-latest.sh
Executable file
40
.ci/sync-latest.sh
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# (c) 2024, Konstantin Demin
|
||||
set -ef
|
||||
|
||||
[ -z "${CI_DEBUG}" ] || set -xv
|
||||
|
||||
: "${IMAGE_NAME:?}" "${EXT_IMAGE_NAME:?}" "${LATEST_TAG:?}"
|
||||
|
||||
. .ci/envsh.registry
|
||||
|
||||
image_src="docker://${IMAGE_NAME}"
|
||||
image_dst="docker://${EXT_IMAGE_NAME}"
|
||||
|
||||
oci_dir="${PWD}/oci-layers"
|
||||
image_interim="oci:${oci_dir}:$(basename "${IMAGE_NAME}"):${LATEST_TAG}"
|
||||
|
||||
rm -rf "${oci_dir}" ; mkdir "${oci_dir}"
|
||||
|
||||
r=0
|
||||
|
||||
img_copy() { skopeo copy --retry-times 3 --all "$@" ; }
|
||||
|
||||
while : ; do
|
||||
img_copy "${image_src}:${LATEST_TAG}" "${image_interim}" || r=$?
|
||||
[ "$r" = 0 ] || break
|
||||
|
||||
echo " -> ${image_src}:latest"
|
||||
img_copy "${image_interim}" "${image_src}:latest" || r=$?
|
||||
[ "$r" = 0 ] || break
|
||||
|
||||
echo " -> ${image_dst}:latest"
|
||||
img_copy "${image_interim}" "${image_dst}:latest" || r=$?
|
||||
[ "$r" = 0 ] || break
|
||||
|
||||
break
|
||||
done
|
||||
|
||||
rm -rf "${oci_dir}"
|
||||
exit "$r"
|
|
@ -1,5 +1,6 @@
|
|||
when:
|
||||
event: [ push, tag, cron, manual ]
|
||||
- event: [ push, tag, cron, manual ]
|
||||
evaluate: 'LATEST_TAG == ""'
|
||||
|
||||
variables:
|
||||
- &image_name 'quay.krd.sh/krd/woodpecker-sonatype-nexus'
|
||||
|
|
43
.woodpecker/.latest.yml
Normal file
43
.woodpecker/.latest.yml
Normal file
|
@ -0,0 +1,43 @@
|
|||
when:
|
||||
- event: [ manual ]
|
||||
evaluate: 'LATEST_TAG != ""'
|
||||
|
||||
variables:
|
||||
- &image_name 'quay.krd.sh/krd/woodpecker-sonatype-nexus'
|
||||
- &ext_image_name 'docker.io/rockdrilla/woodpecker-sonatype-nexus'
|
||||
- &skopeo_image 'quay.krd.sh/quay_io/containers/skopeo:v1.15.0'
|
||||
|
||||
## kind of fixup (remove in near future)
|
||||
## ref: https://github.com/woodpecker-ci/plugin-git/releases
|
||||
clone:
|
||||
git:
|
||||
image: quay.krd.sh/docker_io/woodpeckerci/plugin-git:2.5.0
|
||||
|
||||
## NB: ${variable} expressions are subject to pre-processing.
|
||||
## ref: https://woodpecker-ci.org/docs/usage/environment
|
||||
|
||||
steps:
|
||||
|
||||
- name: verify-registry-credentials
|
||||
image: *skopeo_image
|
||||
environment:
|
||||
GOMAXPROCS: "4"
|
||||
MALLOC_ARENA_MAX: "4"
|
||||
secrets: [ REGISTRY_AUTH ]
|
||||
commands:
|
||||
- .ci/registry-login.sh quay.krd.sh docker.io
|
||||
|
||||
- name: image-sync-latest
|
||||
image: *skopeo_image
|
||||
environment:
|
||||
GOMAXPROCS: "4"
|
||||
MALLOC_ARENA_MAX: "4"
|
||||
##
|
||||
IMAGE_NAME: *image_name
|
||||
EXT_IMAGE_NAME: *ext_image_name
|
||||
commands:
|
||||
- .ci/sync-latest.sh
|
||||
|
||||
## personal tweaks :)
|
||||
labels:
|
||||
network: dmz
|
Loading…
Reference in New Issue
Block a user