From 179e7b5993170b1c2568c23ef173175dd019a19e Mon Sep 17 00:00:00 2001 From: rdev2021 Date: Sat, 23 May 2026 20:33:15 +0530 Subject: [PATCH] patch: added new pacmage support and changes to workflow --- .github/workflows/docker-build.yml | 37 ++++++++++++++++++++++++++++++ Dockerfile | 1 + Readme.md | 19 ++++++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index dade543..8e4b980 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -2,6 +2,7 @@ name: Build and Push Multi-Arch Docker Image on: workflow_dispatch: + pull_request: push: branches: - main @@ -48,3 +49,39 @@ jobs: tags: | ${{ secrets.DOCKER_USERNAME }}/net-utils:latest ghcr.io/${{ github.repository_owner }}/net-utils:latest + + - name: Delete untagged images from GHCR + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + PACKAGE_NAME: net-utils + OWNER: ${{ github.repository_owner }} + run: | + set -euo pipefail + + function check_package() { + local path="$1" + if gh api -H "Accept: application/vnd.github+json" "$path" >/dev/null 2>&1; then + echo "$path" + return 0 + fi + return 1 + } + + PACKAGE_API="" + if PACKAGE_API=$(check_package "/orgs/${OWNER}/packages/container/${PACKAGE_NAME}" 2>/dev/null); then + : + elif PACKAGE_API=$(check_package "/users/${OWNER}/packages/container/${PACKAGE_NAME}" 2>/dev/null); then + : + else + echo "Package not found in org or user scope, skipping cleanup." + exit 0 + fi + + echo "Cleaning untagged versions for package: ${PACKAGE_API}" + gh api -H "Accept: application/vnd.github+json" "${PACKAGE_API}/versions?per_page=100" --paginate --jq '.[] | select(.metadata.container.tags | length == 0) | .id' | while read -r version_id; do + if [[ -n "$version_id" ]]; then + echo "Deleting untagged version ${version_id}" + gh api -X DELETE -H "Accept: application/vnd.github+json" "${PACKAGE_API}/versions/${version_id}" + fi + done diff --git a/Dockerfile b/Dockerfile index 05aa82f..fa819dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ RUN apk update && apk add --no-cache \ netcat-openbsd \ bind-tools \ openssl \ + nmap \ bash CMD ["/bin/bash"] diff --git a/Readme.md b/Readme.md index 45a1383..1e7bacd 100644 --- a/Readme.md +++ b/Readme.md @@ -11,8 +11,25 @@ The image includes the following tools: - `openssl` – Toolkit for SSL/TLS and general cryptography - `dig` – DNS lookup utility - `nslookup` – DNS query tool +- `nmap` – Network mapping and port scanning utility -## Usage in Kubernetes +## Usage + +### Running as a Docker Container + +You can run this image directly using Docker: + +```sh +docker run -it rdev2021/net-utils:latest +``` + +Or with a specific command: + +```sh +docker run -it rdev2021/net-utils:latest curl https://example.com +``` + +### Usage in Kubernetes You can use this image as a temporary debug pod in a Kubernetes cluster.