Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 27 additions & 35 deletions .github/workflows/bb-masking-semantic-type-global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,29 @@ jobs:
id: apply-global-masking-rule
if: ${{ steps.changed-files.outputs.any_changed == 'true' && contains(steps.changed-files.outputs.all_changed_files, 'global-masking-rule.json') }}
run: |
# Process all global-masking-rule.json files
echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep "global-masking-rule.json" | while read -r CHANGED_FILE; do
echo "Processing: $CHANGED_FILE"

response=$(curl -s -w "\n%{http_code}" --request PATCH "${{ steps.bytebase-login.outputs.api_url }}/policies/masking_rule?allow_missing=true&update_mask=payload" \
--header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
--header "Content-Type: application/json" \
--data @"$CHANGED_FILE")

# Extract status code and response body
status_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')

echo "Status code: $status_code"
echo "Response body: $body"

# Append to outputs (with unique identifiers)
echo "${body}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
CHANGED_FILE="masking/global-masking-rule.json"
echo "Processing: $CHANGED_FILE"

response=$(curl -s -w "\n%{http_code}" --request PATCH "${{ steps.bytebase-login.outputs.api_url }}/policies/masking_rule?allow_missing=true&update_mask=payload" \
--header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
--header "Content-Type: application/json" \
--data @"$CHANGED_FILE")

if [[ $status_code -lt 200 || $status_code -ge 300 ]]; then
echo "Failed with status code: $status_code"
exit 1
fi
done
# Extract status code and response body
status_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')

echo "Status code: $status_code"
echo "Response body: $body"

# Append to outputs (with unique identifiers)
echo "${body}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

if [[ $status_code -lt 200 || $status_code -ge 300 ]]; then
echo "Failed with status code: $status_code"
exit 1
fi

- name: Comment on PR
uses: actions/github-script@v7
Expand Down Expand Up @@ -138,19 +136,13 @@ jobs:
let apiCallsFound = false;

if (changedFiles.includes('semantic-type.json')) {
const semanticTypeStatuses = Object.keys(${{ toJSON(steps.apply-semantic-type.outputs) }} || {})
.filter(key => key.startsWith('status_code_'))
.map(key => ({
name: key.replace('status_code_', ''),
status: ${{ toJSON(steps.apply-semantic-type.outputs) }}[key]
}));

semanticTypeStatuses.forEach(({name, status}) => {
const status = ${{ toJSON(steps.apply-semantic-type.outputs) }}.status_code;
if (status) {
apiCallsFound = true;
const success = status >= 200 && status < 300;
commentBody += `- Semantic Type (${name}): ${success ? '✅' : '❌'} ${status}\n`;
});
}
commentBody += `- Semantic Type: ${success ? '✅' : '❌'} ${status}\n`;
}
}

if (changedFiles.includes('global-masking-rule.json')) {
const status = ${{ toJSON(steps.apply-global-masking-rule.outputs) }}.status_code;
Expand Down
2 changes: 1 addition & 1 deletion masking/global-masking-rule.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"id": "76356d81-6231-4128-9be7-2c549fc505f5",
"condition": {
"expression": "classification_level in [\"2\", \"3\"]",
"expression": "classification_level in [\"2\"]",
"title": "",
"description": ""
},
Expand Down
2 changes: 1 addition & 1 deletion masking/semantic-type.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"id": "e8d3fd41-eba0-4afd-ae0f-32c91a4ee710",
"title": "Personal sensitive data",
"title": "Personal sensitive data x",
"description": "Custom semantic type with full masking for personal sensitive data",
"algorithm": {
"fullMask": {
Expand Down
Loading