ci: link container package to repository
Build and push backend image / backend-image (push) Successful in 15s

This commit is contained in:
2026-09-23 00:33:05 +08:00
parent a2b76f2a3b
commit bd3e786e78
+28
View File
@@ -45,3 +45,31 @@ jobs:
docker tag "$image:$IMAGE_TAG" "$image:latest"
docker push "$image:latest"
fi
- name: Link package to repository
env:
GITEA_API: https://git.ipao.vip/api/v1
GITEA_OWNER: ${{ github.repository_owner }}
PACKAGE_NAME: ${{ github.event.repository.name }}
PACKAGE_VERSION: ${{ github.sha }}
REPOSITORY_NAME: ${{ github.event.repository.name }}
GITEA_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
set -eu
test -n "$GITEA_TOKEN"
expected_repo="$GITEA_OWNER/$REPOSITORY_NAME"
package_json="$(curl -fsS \
--header "Authorization: token $GITEA_TOKEN" \
"$GITEA_API/packages/$GITEA_OWNER/container/$PACKAGE_NAME/$PACKAGE_VERSION")"
linked_repo="$(printf '%s' "$package_json" | jq -r '.repository.full_name // empty')"
if [ -n "$linked_repo" ]; then
if [ "$linked_repo" != "$expected_repo" ]; then
echo "package is already linked to $linked_repo" >&2
exit 1
fi
echo "package already linked to $linked_repo"
exit 0
fi
curl -fsS -X POST \
--header "Authorization: token $GITEA_TOKEN" \
"$GITEA_API/packages/$GITEA_OWNER/container/$PACKAGE_NAME/-/link/$REPOSITORY_NAME"