Skip to content

update #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2025
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
19 changes: 17 additions & 2 deletions .github/workflows/4-bb-export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
return 1
fi

# Check if the response is valid JSON
# Simple one-line JSON validation
if ! python3 -c "import json,sys; json.load(open('$temp_file'))" 2>/dev/null; then
echo "Error: Invalid JSON response"
echo "Response content:"
Expand Down Expand Up @@ -135,8 +135,9 @@ jobs:
echo "==========================="

for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "Processing $file"
echo "Processing $file ================================================"
SQL_CONTENT=$(base64 < "$file")
echo "finishing processing $file ======================="
echo "SQL_CONTENT=$SQL_CONTENT" >> $GITHUB_ENV
STEP_ID=$(python3 -c "import uuid; print(str(uuid.uuid4()))")
echo "STEP_ID=$STEP_ID" >> $GITHUB_ENV
Expand All @@ -150,31 +151,45 @@ jobs:
"{\"title\":\"\",\"content\":\"$SQL_CONTENT\",\"type\":\"TYPE_SQL\",\"source\":\"SOURCE_BYTEBASE_ARTIFACT\",\"visibility\":\"VISIBILITY_PUBLIC\"}" \
"Create Sheet")

echo "finishing sheetdata ================================================"

SHEET_NAME=$(echo "$sheet_data" | python3 -c "import sys, json; print(json.load(sys.stdin)['name'])")

echo "finishing sheetname ================================================"

plan_data=$(call_api \
"$BASE_URL/projects/$PROJECT/plans" \
"POST" \
"{\"steps\":[{\"specs\":[{\"id\":\"$STEP_ID\",\"export_data_config\":{\"target\":\"/instances/$INSTANCE/databases/$DATABASE\",\"format\":\"$FORMAT\",\"sheet\":\"$SHEET_NAME\"}}]}],\"title\":\"Export data from $DATABASE\",\"description\":\"EXPORT\"}" \
"Create Plan")

echo "finishing plan_data ================================================"

PLAN_NAME=$(echo "$plan_data" | python3 -c "import sys, json; print(json.load(sys.stdin)['name'])")

echo "finishing plan_name ================================================"

issue_data=$(call_api \
"$BASE_URL/projects/$PROJECT/issues" \
"POST" \
"{\"approvers\":[],\"approvalTemplates\":[],\"subscribers\":[],\"title\":\"Issue: Export data from instances/$INSTANCE/databases/$DATABASE\",\"description\":\"SQL request from GitHub\",\"type\":\"DATABASE_DATA_EXPORT\",\"assignee\":\"\",\"plan\":\"$PLAN_NAME\"}" \
"Create Issue")

echo "finishing issue_data ================================================"

rollout_data=$(call_api \
"$BASE_URL/projects/$PROJECT/rollouts" \
"POST" \
"{\"plan\":\"$PLAN_NAME\"}" \
"Create Rollout")

echo "finishing rollout_data ================================================"

ISSUE_NUMBER=$(echo "$issue_data" | python3 -c "import sys, json; print(json.load(sys.stdin)['name'].split('/')[-1])")
ISSUE_LINK="${{ secrets.BYTEBASE_URL }}/projects/$PROJECT/issues/$ISSUE_NUMBER"
echo "ISSUE_LINK=$ISSUE_LINK" >> $GITHUB_ENV

echo "finishing issue_link ================================================"
done

- name: Comment on PR
Expand Down
Loading