Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e0d247e

Browse files
update
1 parent bab3ac3 commit e0d247e

File tree

2 files changed

+25
-38
lines changed

2 files changed

+25
-38
lines changed

‎.github/workflows/4-bb-export.yml‎

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
export/**/*.sql
4040
since_last_remote_commit: true
4141

42+
- name: Install jq
43+
run: sudo apt-get install -y jq
44+
4245
- name: Process SQL files
4346
id: process-sql
4447
if: steps.changed-files.outputs.any_changed == 'true'
@@ -60,8 +63,10 @@ jobs:
6063
--data "$data" \
6164
-o "$temp_file")
6265
63-
# Return the response regardless of status code
64-
# This allows the caller to handle the response
66+
echo "Response (Status $http_code):"
67+
cat "$temp_file" | jq '.'
68+
echo "------------------------"
69+
6570
cat "$temp_file"
6671
}
6772
@@ -104,68 +109,50 @@ jobs:
104109
echo "==========================="
105110
106111
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
107-
echo "DEBUG: Starting to process file: $file"
112+
echo "Processing $file"
108113
SQL_CONTENT=$(base64 < "$file")
109-
echo "DEBUG: SQL content encoded"
110114
STEP_ID=$(python3 -c "import uuid; print(str(uuid.uuid4()))")
111115
BASE_URL="${{ steps.bytebase-login.outputs.api_url }}"
112-
113-
echo "DEBUG: About to make first API call to create sheet"
114-
response=$(call_api \
116+
117+
# Create Sheet
118+
sheet_data=$(call_api \
115119
"$BASE_URL/projects/$PROJECT/sheets" \
116120
"POST" \
117121
"{\"title\":\"\",\"content\":\"$SQL_CONTENT\",\"type\":\"TYPE_SQL\",\"source\":\"SOURCE_BYTEBASE_ARTIFACT\",\"visibility\":\"VISIBILITY_PUBLIC\"}" \
118122
"Create Sheet")
119123
120-
echo "DEBUG: Raw API Response:"
121-
echo "$response"
122-
123-
# Option 1: Using grep and cut
124-
SHEET_NAME=$(echo "$response" | grep -o '"name":"[^"]*"' | cut -d'"' -f4)
125-
126-
# Option 2: Using sed
127-
# SHEET_NAME=$(echo "$response" | sed -n 's/.*"name":"\([^"]*\)".*/1円/p')
128-
129-
# Option 3: Using jq if available
130-
# SHEET_NAME=$(echo "$response" | jq -r '.name')
131-
132-
echo "DEBUG: Retrieved sheet name: $SHEET_NAME"
133-
134-
echo "finishing sheetname ================================================"
124+
SHEET_NAME=$(echo "$sheet_data" | jq -r '.name')
125+
echo "Sheet name: $SHEET_NAME"
135126
127+
# Create Plan
136128
plan_data=$(call_api \
137129
"$BASE_URL/projects/$PROJECT/plans" \
138130
"POST" \
139131
"{\"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\"}" \
140132
"Create Plan")
133+
134+
PLAN_NAME=$(echo "$plan_data" | jq -r '.name')
135+
echo "Plan name: $PLAN_NAME"
141136
142-
echo "finishing plan_data ================================================"
143-
144-
PLAN_NAME=$(echo "$plan_data" | python3 -c "import sys, json; print(json.load(sys.stdin)['name'])")
145-
146-
echo "finishing plan_name ================================================"
147-
137+
# Create Issue
148138
issue_data=$(call_api \
149139
"$BASE_URL/projects/$PROJECT/issues" \
150140
"POST" \
151141
"{\"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\"}" \
152142
"Create Issue")
143+
144+
ISSUE_NUMBER=$(echo "$issue_data" | jq -r '.name | split("/")[-1]')
145+
ISSUE_LINK="${{ secrets.BYTEBASE_URL }}/projects/$PROJECT/issues/$ISSUE_NUMBER"
146+
echo "Issue link: $ISSUE_LINK"
153147
154-
echo "finishing issue_data ================================================"
155-
148+
# Create Rollout
156149
rollout_data=$(call_api \
157150
"$BASE_URL/projects/$PROJECT/rollouts" \
158151
"POST" \
159152
"{\"plan\":\"$PLAN_NAME\"}" \
160153
"Create Rollout")
161-
162-
echo "finishing rollout_data ================================================"
163-
164-
ISSUE_NUMBER=$(echo "$issue_data" | python3 -c "import sys, json; print(json.load(sys.stdin)['name'].split('/')[-1])")
165-
ISSUE_LINK="${{ secrets.BYTEBASE_URL }}/projects/$PROJECT/issues/$ISSUE_NUMBER"
166-
echo "ISSUE_LINK=$ISSUE_LINK" >> $GITHUB_ENV
167-
168-
echo "finishing issue_link ================================================"
154+
155+
echo "Rollout created: $(echo "$rollout_data" | jq -r '.name')"
169156
done
170157
171158
- name: Comment on PR
File renamed without changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /