@@ -21,18 +21,15 @@ 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.
24+ container :
25+ image : docker://bytebase/bytebase-action:latest
2726 outputs :
28- bytebase-plan : ${{ steps.create-plan.outputs.plan }}
27+ bytebase-plan : ${{ steps.create-plan.outputs.plan }}
2928 deployment-required : ${{ steps.create-plan.outputs.deployment-required }}
3029 steps :
3130 - name : Checkout
3231 uses : actions/checkout@v4
3332 - name : rollout
34- id : bytebase_rollout # Added an id for potential future use with outputs
35- uses : docker://bytebase/bytebase-action:latest
3633 env :
3734 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3835 BYTEBASE_URL : https://demo.bytebase.com
@@ -42,72 +39,12 @@ jobs:
4239 BYTEBASE_TARGETS : " instances/test-sample-instance/databases/hr_test,instances/prod-sample-instance/databases/hr_prod"
4340 BYTEBASE_TARGET_STAGE : environments/test
4441 FILE_PATTERN : " migrations/*.sql"
45- # Define the output path using runner.temp; GitHub Actions should handle syncing this
46- BYTEBASE_OUTPUT_FILE_PATH : " ${{ runner.temp }}/bytebase-metadata.json"
47- with :
48- entrypoint : /bin/sh
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- "
42+ BYTEBASE_OUTPUT : ${{ runner.temp }}/bytebase-metadata.json
43+ run : |
44+ 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 }}
45+ ls -al ${{ runner.temp }}
9946 - 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()
10247 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:"
10748 ls -al ${{ runner.temp }}
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
49+ echo "Output: ${{ runner.temp }}/bytebase-metadata.json"
50+ cat ${{ runner.temp }}/bytebase-metadata.json
0 commit comments