Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
kyuhank committed Feb 7, 2025
1 parent 53d3c35 commit d43f623
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
branches:
- main
paths:
- "**/**" # Detect changes in any path
- "**/**" # Detect any file changes at top level

permissions:
contents: read
Expand All @@ -29,8 +29,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v3
with:
# Ensure we have a previous commit for diff
fetch-depth: 2
fetch-depth: 2 # Ensure we have a previous commit if it exists

##################################################################
# 2) CONVERT REPO OWNER TO LOWERCASE
Expand All @@ -46,7 +45,7 @@ jobs:
run: |
echo "=== Detecting changed top-level directories ==="
# If there's a previous commit, find changed directories
# If there's a previous commit, detect what changed
if git rev-parse HEAD^ >/dev/null 2>&1; then
CHANGED_DIRS=$(git diff --name-only HEAD^ HEAD -- | awk -F/ '{print $1}' | sort -u | grep -v '^\.' || true)
else
Expand All @@ -56,19 +55,19 @@ jobs:
echo "Raw changed directories: $CHANGED_DIRS"
# Convert to space-separated for looping
# Make space-separated list
echo "CHANGED_DIRS=$(echo "$CHANGED_DIRS" | tr '\n' ' ')" >> $GITHUB_ENV
##################################################################
# 4) LOG IN TO GHCR (SECURELY, WITH EPHEMERAL CONFIG)
##################################################################
- name: Log in Securely to GitHub Container Registry
- name: Log in to GitHub Container Registry (Secure)
run: |
mkdir -p /tmp/docker-config
export DOCKER_CONFIG=/tmp/docker-config
echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
echo "Successfully logged in with ephemeral Docker config at $DOCKER_CONFIG"
echo "Successfully logged in using ephemeral Docker config at $DOCKER_CONFIG"
##################################################################
# 5) BUILD AND PUSH DOCKER IMAGES
Expand All @@ -95,7 +94,7 @@ jobs:
echo "=== Processing directory: $dir ==="
# If user specified a version, use that; otherwise auto-detect
# If user specified a version, use that; otherwise, auto-detect
if [ -n "$USER_SPECIFIED_VERSION" ]; then
NEW_VERSION="$USER_SPECIFIED_VERSION"
echo "Using user-specified version: $NEW_VERSION"
Expand Down Expand Up @@ -124,7 +123,7 @@ jobs:
NEW_VERSION="1.0"
echo "GHCR response not an array. Starting at 1.0."
else
# Regex allows optional 'v': ^v?[0-9]+\.[0-9]+$
# Regex allows optional 'v' prefix: ^v?[0-9]+\.[0-9]+$
VERSION_TAGS=$(echo "$API_RESPONSE" | jq -r '
[.[].metadata.container.tags? // [] | .[]]
| map(select(test("^v?[0-9]+\\.[0-9]+$") and . != "latest"))
Expand All @@ -135,7 +134,7 @@ jobs:
NEW_VERSION="1.0"
echo "No valid versions found for '$dir'. Starting at 1.0."
else
# Remove leading 'v' if present, then increment minor
# Strip leading 'v' if present, then increment minor
CLEAN_VERSION=$(echo "$VERSION_TAGS" | sed 's/^v//')
NEW_VERSION=$(awk -F. '{print $1 "." $2+1}' <<< "$CLEAN_VERSION")
echo "Latest version: $CLEAN_VERSION => Incremented to: $NEW_VERSION"
Expand All @@ -146,7 +145,6 @@ jobs:
echo "Final version for '$dir': $NEW_VERSION"
# Build & Push
IMAGE_NAME="ghcr.io/${{ env.OWNER }}/$dir"
echo "Docker Image Name: $IMAGE_NAME"
echo "=== Building Docker image: $IMAGE_NAME:v$NEW_VERSION ==="
Expand All @@ -156,4 +154,4 @@ jobs:
docker push "$IMAGE_NAME:latest"
echo "=== Done with $dir (version $NEW_VERSION) ==="
done

0 comments on commit d43f623

Please sign in to comment.