Add gitea-actions: Spring Boot 4.2.0 CI with surefire/failsafe, Testcontainers, CycloneDX SBOM and Jib
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b69H5rTewUKPyhGS8r
This commit is contained in:
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# What actually happens when the pipeline pushes to a Gitea that lives under a URL sub-path.
|
||||
# Needs GITEA_TOKEN (a personal access token with write:package). Never printed, never committed.
|
||||
source "$(dirname "$0")/lib.sh"
|
||||
: "${GITEA_TOKEN:?export GITEA_TOKEN first}"
|
||||
BASE="${GITEA_BASE:-https://ankurm.com/git.app}"; HOST="${GITEA_HOST:-ankurm.com}"; OWNER="${GITEA_OWNER:-asmhatre}"
|
||||
VER="1.0.0-demo"
|
||||
{
|
||||
banner "1. Where does the container registry answer?"
|
||||
printf '%s/v2/ -> HTTP %s\n' "https://$HOST" "$(curl -s -o /dev/null -w '%{http_code}' -u "$OWNER:$GITEA_TOKEN" "https://$HOST/v2/")"
|
||||
printf '%s/v2/ -> HTTP %s\n' "$BASE" "$(curl -s -o /dev/null -w '%{http_code}' -u "$OWNER:$GITEA_TOKEN" "$BASE/v2/")"
|
||||
banner "2. docker login and docker push the way every tutorial writes it"
|
||||
echo "\$ docker login $HOST"
|
||||
echo "$GITEA_TOKEN" | docker login "$HOST" -u "$OWNER" --password-stdin 2>&1 | grep -v '^$' || true
|
||||
docker tag postgres:17-alpine "$HOST/$OWNER/gitea-actions-probe:1"
|
||||
echo "\$ docker push $HOST/$OWNER/gitea-actions-probe:1"
|
||||
docker push "$HOST/$OWNER/gitea-actions-probe:1" 2>&1 | tail -1 || true
|
||||
docker rmi "$HOST/$OWNER/gitea-actions-probe:1" >/dev/null 2>&1 || true
|
||||
banner "3. The generic package registry works under the sub-path: upload the SBOM"
|
||||
URL="$BASE/api/packages/$OWNER/generic/gitea-actions-demo-sbom/$VER/application.cdx.json"
|
||||
echo "\$ curl --upload-file target/classes/META-INF/sbom/application.cdx.json $BASE/api/packages/$OWNER/generic/gitea-actions-demo-sbom/$VER/application.cdx.json"
|
||||
printf 'PUT first time -> HTTP %s\n' "$(curl -s -o /dev/null -w '%{http_code}' -u "$OWNER:$GITEA_TOKEN" --upload-file target/classes/META-INF/sbom/application.cdx.json "$URL")"
|
||||
printf 'PUT second time -> HTTP %s (a file name can be published once per version)\n' "$(curl -s -o /dev/null -w '%{http_code}' -u "$OWNER:$GITEA_TOKEN" --upload-file target/classes/META-INF/sbom/application.cdx.json "$URL")"
|
||||
curl -s -u "$OWNER:$GITEA_TOKEN" "$URL" | python3 -c "import sys,json; b=json.load(sys.stdin); print('downloaded back:', b['bomFormat'], b['specVersion'], len(b['components']), 'components')"
|
||||
printf 'DELETE version -> HTTP %s\n' "$(curl -s -o /dev/null -w '%{http_code}' -u "$OWNER:$GITEA_TOKEN" -X DELETE "$BASE/api/packages/$OWNER/generic/gitea-actions-demo-sbom/$VER")"
|
||||
banner "4. Bad file name"
|
||||
printf 'PUT file with a space in its name -> HTTP %s\n' "$(curl -s -o /dev/null -w '%{http_code}' -u "$OWNER:$GITEA_TOKEN" --upload-file target/classes/META-INF/sbom/application.cdx.json "$BASE/api/packages/$OWNER/generic/gitea-actions-demo-sbom/$VER/application%20x.cdx.json")"
|
||||
printf 'DELETE version (cleanup) -> HTTP %s\n' "$(curl -s -o /dev/null -w '%{http_code}' -u "$OWNER:$GITEA_TOKEN" -X DELETE "$BASE/api/packages/$OWNER/generic/gitea-actions-demo-sbom/$VER")"
|
||||
printf 'packages left named gitea-actions-demo-sbom: %s\n' "$(curl -s -u "$OWNER:$GITEA_TOKEN" "$BASE/api/v1/packages/$OWNER?q=gitea-actions-demo-sbom" | python3 -c 'import sys,json; print(len(json.load(sys.stdin)))')"
|
||||
} 2>&1 | sed "s/$GITEA_TOKEN/***/g" | tee "$OUT/06-gitea-registries.txt"
|
||||
docker logout "$HOST" >/dev/null 2>&1 || true
|
||||
Reference in New Issue
Block a user