@@ -26,27 +26,27 @@ jobs:
2626 - name : Check if latest commit modifies images.windowsAgent.tag
2727 id : version-check
2828 run : |
29- DIFF_OUTPUT=$(git diff HEAD~1 -- charts/newrelic-infrastructure/values.yaml)
30- TAG_OLD=""
29+ DIFF_OUTPUT=$(git diff HEAD~1 HEAD -- charts/newrelic-infrastructure/values.yaml)
3130 TAG_NEW=""
3231 VERSION_CHANGED="false"
3332
34- CHUNK=$( echo "$DIFF_OUTPUT" | awk '/images:/,/\}/' | awk '/ windowsAgent:/,/^\s*[a-z]/')
33+ if echo "$DIFF_OUTPUT" | grep -q " windowsAgent:"; then
3534
36- if echo "$CHUNK" | grep -E "^[+-]\s+tag:" > /dev/null; then
37- TAG_NEW=$(echo "$CHUNK" | grep -E "^\+\s+tag:" | sed 's/^\+\s\+tag:\s\+//')
38-
39- # Set version changed flag to true
40- VERSION_CHANGED="true"
35+ WINDOW_AGENT_SECTION=$(echo "$DIFF_OUTPUT" | sed -n '/windowsAgent:/,/pullPolicy:/p')
36+ echo "WINDOW_AGENT_SECTION: $WINDOW_AGENT_SECTION"
4137
42- echo "Tag was changed from to $TAG_NEW in windowsAgent section"
38+ if echo "$WINDOW_AGENT_SECTION" | grep -E -q "^[+-][ ]+tag:"; then
39+ TAG_NEW=$(echo "$WINDOW_AGENT_SECTION" | grep -E "^\+[ ]+tag:" | awk '{print $2}')
40+ VERSION_CHANGED="true"
41+ echo "WindowsAgent tag was changed to $TAG_NEW"
42+ else
43+ echo "No tag changes in windowsAgent section"
44+ fi
4345 else
44- echo "No tag changes in windowsAgent section "
46+ echo "WindowsAgent section not found in diff "
4547 fi
4648
47- # Output the variables for GitHub Actions
48- echo "tag_old=$TAG_OLD" >> $GITHUB_OUTPUT
49- echo "tag_new=$TAG_NEW" >> $GITHUB_OUTPUT
49+ echo "new_agent_version=$TAG_NEW" >> $GITHUB_OUTPUT
5050 echo "version_changed=$VERSION_CHANGED" >> $GITHUB_OUTPUT
5151
5252 build :
0 commit comments