Skip to content

Commit

Permalink
NIT-1253 add validation to ensure new snippet isn't added multipe times
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmooreio committed May 15, 2024
1 parent f1ad248 commit 8d840ee
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/read-only-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ jobs:
# If read-only mode is enabled, append the new snippet to the current one, otherwise remove it
if [[ ${{ inputs.enable }} == "true" ]]; then
FINAL_SNIPPET="$CURRENT_SNIPPET"$'\n'"$NEW_SNIPPET"
if echo "$CURRENT_SNIPPET" | grep -q "$NEW_SNIPPET"; then
echo "Read-only mode is already enabled"
exit 0
else
FINAL_SNIPPET="$CURRENT_SNIPPET"$'\n'"$NEW_SNIPPET"
fi
else
FINAL_SNIPPET=$(echo "$CURRENT_SNIPPET" | sed -e "s/$NEW_SNIPPET//" -e '/^$/d')
fi
Expand Down

0 comments on commit 8d840ee

Please sign in to comment.