-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90eae7d
commit c7779f9
Showing
1 changed file
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Tilt Geo Extraction | ||
name: Tilt Extraction | ||
|
||
on: | ||
push: | ||
|
@@ -44,17 +44,37 @@ jobs: | |
done | ||
fi | ||
- name: Extract category and update deployment.yaml | ||
run: | | ||
# Extract category from tilt.json | ||
CATEGORIES=$(jq -r '.dataDisclosed[]?.recipients[]?.category | select(.!=null)' tilt.json) | ||
# Print the extracted categories | ||
echo "Extracted Countries: $CATEGORIES" | ||
# Check if there are any categories extracted | ||
if [ -n "$CATEGORIES" ]; then | ||
# Update deployment.yaml for each category | ||
for CATEGORY in $CATEGORIES; do | ||
LABEL="cat-$CATEGORY: \"true\"" | ||
# Check and append the label with correct indentation under metadata/labels. Only does this at the first instance of labels and not for subsequent instances. | ||
# IMPORTANT: This assumes that the labels are indented with 4 spaces. If the indentation is different, this will not work. | ||
# ALSO: This assumes that the labels are the first entry under metadata. If the labels are under some other section or not the first entry, this will not work. | ||
awk -v label="$LABEL" 'BEGIN {append=0} /metadata:/ {print; getline; if ($1 == "labels:" && append == 0) {print; print " " label; append=1; next}}1' dev/deployment.yaml > dev/deployment_temp.yaml && mv dev/deployment_temp.yaml dev/deployment.yaml | ||
done | ||
fi | ||
- name: Commit and push if changed | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
# Add all three potentially modified deployment.yaml files | ||
# Add every potentially modified deployment.yaml file | ||
git add apps/catalogue/deployment.yaml | ||
git add apps/orders/deployment.yaml | ||
git add apps/payment/deployment.yaml | ||
git add apps/shipping/deployment.yaml | ||
# Commit and push if there are any changes | ||
git diff-index --quiet HEAD || git commit -m "Update deployment.yaml files with geo label from tilt.json" | ||
git push | ||
git diff-index --quiet HEAD || git commit -m "Add tilt-labels to deployment files" | ||
git push |