Skip to content

Commit

Permalink
Add category extraction job
Browse files Browse the repository at this point in the history
  • Loading branch information
louisloechel committed Oct 30, 2023
1 parent 90eae7d commit c7779f9
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tilt Geo Extraction
name: Tilt Extraction

on:
push:
Expand Down Expand Up @@ -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

0 comments on commit c7779f9

Please sign in to comment.