From 1055aec066e01f9917baf4c58dcd26b0822b9760 Mon Sep 17 00:00:00 2001 From: tommy Date: Sun, 5 Jan 2025 11:23:21 +0000 Subject: [PATCH] Update .forgejo/workflows/release-charts.yaml --- .forgejo/workflows/release-charts.yaml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.forgejo/workflows/release-charts.yaml b/.forgejo/workflows/release-charts.yaml index b7984f6..2137d18 100644 --- a/.forgejo/workflows/release-charts.yaml +++ b/.forgejo/workflows/release-charts.yaml @@ -20,7 +20,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: - fetch-depth: 0 # Ensures full history for accurate diffing + fetch-depth: 0 - name: Identify Merge Commit and List Changed Charts id: changed-charts @@ -33,10 +33,8 @@ jobs: if [ "$PARENT_COUNT" -gt 2 ]; then echo "This is a merge commit with $((PARENT_COUNT - 1)) parents." - # For simplicity, comparing with the first parent PARENT_SHA=$(git rev-parse HEAD^1) elif [ "$PARENT_COUNT" -eq 2 ]; then - # Regular commit with one parent PARENT_SHA=$(git rev-parse HEAD^1) else echo "Single commit with no parents. Listing all changes." @@ -46,20 +44,24 @@ jobs: echo "Current Commit SHA: $CURRENT_SHA" echo "Parent Commit SHA: $PARENT_SHA" - # List changed files between parent and current commit - CHANGED_FILES=$(git diff --name-only $PARENT_SHA $CURRENT_SHA) + # List changed files and trim any extra line breaks + CHANGED_FILES=$(git diff --name-only $PARENT_SHA $CURRENT_SHA | tr -d '\r') echo "Changed files:" echo "$CHANGED_FILES" - # Filter changed files to include only those in 'charts/**' - CHANGED_CHARTS=$(echo "$CHANGED_FILES" | grep '^charts/' | awk -F/ '{print $2}' | sort -u) + # Extract chart directories + CHANGED_CHARTS=$(echo "$CHANGED_FILES" | grep '^charts/' | awk -F/ '{print $2}' | sort -u | tr -d '\r') echo "Changed charts:" echo "$CHANGED_CHARTS" # Convert to JSON array - CHANGED_CHARTS_JSON=$(echo "$CHANGED_CHARTS" | jq -R -s -c 'split("\n") | map(select(length > 0))') + if [ -z "$CHANGED_CHARTS" ]; then + CHANGED_CHARTS_JSON="[]" + else + CHANGED_CHARTS_JSON=$(echo "$CHANGED_CHARTS" | jq -R -s -c 'split("\n") | map(select(length > 0))') + fi echo "reposChanged=$CHANGED_CHARTS_JSON" >> $GITHUB_OUTPUT