Skip to content

Commit 5e05c8e

Browse files
committed
gemini attempt 1
1 parent 2a8e1aa commit 5e05c8e

File tree

1 file changed

+69
-5
lines changed

1 file changed

+69
-5
lines changed

.github/workflows/release-action.yml

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ jobs:
2121
deploy-to-all:
2222
needs: build
2323
runs-on: ubuntu-latest # use self-hosted machines if your Bytebase runs in internal networks.
24+
# Note: The 'outputs' section below refers to 'steps.create-plan',
25+
# which is not defined in this job. You might need to adjust this
26+
# if you intend to output data from the 'rollout' step.
2427
outputs:
25-
bytebase-plan: ${{ steps.create-plan.outputs.plan }}
28+
bytebase-plan: ${{ steps.create-plan.outputs.plan }}
2629
deployment-required: ${{ steps.create-plan.outputs.deployment-required }}
2730
steps:
2831
- name: Checkout
2932
uses: actions/checkout@v4
3033
- name: rollout
34+
id: bytebase_rollout # Added an id for potential future use with outputs
3135
uses: docker://bytebase/bytebase-action:latest
3236
env:
3337
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -38,12 +42,72 @@ jobs:
3842
BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test,instances/prod-sample-instance/databases/hr_prod"
3943
BYTEBASE_TARGET_STAGE: environments/test
4044
FILE_PATTERN: "migrations/*.sql"
41-
BYTEBASE_OUTPUT: ${{ runner.temp }}/bytebase-metadata.json
45+
# Define the output path using runner.temp; GitHub Actions should handle syncing this
46+
BYTEBASE_OUTPUT_FILE_PATH: "${{ runner.temp }}/bytebase-metadata.json"
4247
with:
4348
entrypoint: /bin/sh
44-
args: -c 'bytebase-action rollout --url=${{ env.BYTEBASE_URL }} --service-account=${{ env.BYTEBASE_SERVICE_ACCOUNT }} --service-account-secret=${{ env.BYTEBASE_SERVICE_ACCOUNT_SECRET }} --project=${{ env.BYTEBASE_PROJECT }} --file-pattern=${{ env.FILE_PATTERN }} --targets=${{ env.BYTEBASE_TARGETS }} --target-stage=${{ env.BYTEBASE_TARGET_STAGE }} --output=${{ env.BYTEBASE_OUTPUT }} && ls -al ${{ runner.temp }}'
49+
args: |
50+
-c "
51+
echo '--- Starting bytebase-action script ---'
52+
echo 'Runner temp directory (inside container context): ${{ runner.temp }}'
53+
echo 'Target output file path: ${{ env.BYTEBASE_OUTPUT_FILE_PATH }}'
54+
55+
# Ensure the target directory for the output file exists
56+
# dirname needs the path, so quote it properly
57+
TARGET_DIR=$(dirname \"${{ env.BYTEBASE_OUTPUT_FILE_PATH }}\")
58+
echo \"Ensuring output directory exists: $TARGET_DIR\"
59+
mkdir -p \"$TARGET_DIR\"
60+
61+
echo 'Executing: bytebase-action rollout ...'
62+
# Execute the bytebase-action command
63+
# Ensure arguments with environment variables are properly quoted if they might contain spaces
64+
# or special characters, though for these specific env vars, it might not be strictly needed.
65+
bytebase-action rollout \
66+
--url='${{ env.BYTEBASE_URL }}' \
67+
--service-account='${{ env.BYTEBASE_SERVICE_ACCOUNT }}' \
68+
--service-account-secret='${{ env.BYTEBASE_SERVICE_ACCOUNT_SECRET }}' \
69+
--project='${{ env.BYTEBASE_PROJECT }}' \
70+
--file-pattern='${{ env.FILE_PATTERN }}' \
71+
--targets='${{ env.BYTEBASE_TARGETS }}' \
72+
--target-stage='${{ env.BYTEBASE_TARGET_STAGE }}' \
73+
--output='${{ env.BYTEBASE_OUTPUT_FILE_PATH }}'
74+
75+
ACTION_EXIT_CODE=$?
76+
echo \"bytebase-action rollout command finished with exit code: $ACTION_EXIT_CODE\"
77+
78+
# Check if the action succeeded and if the file was created
79+
if [ $ACTION_EXIT_CODE -eq 0 ]; then
80+
echo 'Action succeeded. Checking for output file existence inside container script:'
81+
if [ -f \"${{ env.BYTEBASE_OUTPUT_FILE_PATH }}\" ]; then
82+
echo 'Output file FOUND by script:'
83+
ls -l \"${{ env.BYTEBASE_OUTPUT_FILE_PATH }}\"
84+
echo '--- Content of output file (from inside action script) ---'
85+
cat \"${{ env.BYTEBASE_OUTPUT_FILE_PATH }}\"
86+
echo '--- End of content ---'
87+
else
88+
echo 'Output file NOT FOUND by script at ${{ env.BYTEBASE_OUTPUT_FILE_PATH }}.'
89+
echo 'Listing directory contents of $TARGET_DIR:'
90+
ls -la \"$TARGET_DIR\"
91+
fi
92+
else
93+
echo 'bytebase-action command failed (exit code $ACTION_EXIT_CODE), skipping output file check by script.'
94+
fi
95+
echo '--- Ending bytebase-action script ---'
96+
# Propagate the exit code of the bytebase-action command
97+
exit $ACTION_EXIT_CODE
98+
"
4599
- name: Check output
100+
# This step will run by default only if the 'rollout' step succeeds.
101+
# If you want it to run even if 'rollout' fails (e.g., for debugging), add: if: always()
46102
run: |
103+
echo "--- Check output step on runner ---"
104+
echo "Runner temp directory (on runner): ${{ runner.temp }}"
105+
echo "Expected output file (on runner): ${{ runner.temp }}/bytebase-metadata.json"
106+
echo "Listing contents of ${{ runner.temp }} on runner:"
47107
ls -al ${{ runner.temp }}
48-
echo "Output: ${{ runner.temp }}/bytebase-metadata.json"
49-
cat ${{ runner.temp }}/bytebase-metadata.json
108+
echo "Attempting to cat the file from runner:"
109+
# Use the same env var name for consistency, or the direct path
110+
cat ${{ env.BYTEBASE_OUTPUT_FILE_PATH }} # This env var was set in the previous step,
111+
# but it's better to use the known path directly if env var scope is an issue.
112+
# Using the explicit path:
113+
# cat ${{ runner.temp }}/bytebase-metadata.json

0 commit comments

Comments
 (0)