Skip to content

Commit

Permalink
chore: add branch_example.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
earayu committed Dec 17, 2024
1 parent 8e7a695 commit 081c2b1
Showing 1 changed file with 16 additions and 97 deletions.
113 changes: 16 additions & 97 deletions .github/workflows/branch_example.yml
Original file line number Diff line number Diff line change
@@ -1,107 +1,26 @@
name: Branch Example

on:
workflow_dispatch:
inputs:
source_host:
description: 'Source host address'
required: true
type: string
source_port:
description: 'Source port'
required: false
type: string
default: '3306'
source_user:
description: 'Source user'
required: false
type: string
default: 'root'
source_password:
description: 'Source password'
required: true
type: string
default: ''
include_databases:
description: 'Databases to include'
required: false
type: string
default: '*'
exclude_databases:
description: 'Databases to exclude'
required: false
type: string
default: 'information_schema,mysql,performance_schema,sys'
wescale_image:
description: 'WeScale image tag'
required: false
type: string
default: 'apecloud/apecloud-mysql-scale:0.3.8'
push:

jobs:
build:
setup-mysql:
runs-on: ubuntu-latest
env:
SOURCE_HOST: ${{ inputs.source_host || '47.93.127.119' }}
SOURCE_PORT: ${{ inputs.source_port || '15306' }}
SOURCE_USER: ${{ inputs.source_user || 'root' }}
SOURCE_PASSWORD: ${{ inputs.source_password || '' }}
INCLUDE_DATABASES: ${{ inputs.include_databases || '*' }}
EXCLUDE_DATABASES: ${{ inputs.exclude_databases || 'information_schema,mysql,performance_schema,sys' }}
WESCALE_IMAGE: ${{ inputs.wescale_image || 'apecloud/apecloud-mysql-scale:0.3.8' }}

steps:
- name: Set Up Target Cluster
run: |
docker run -itd --network host --name mysql-server \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=passwd \
-e MYSQL_ROOT_HOST=% \
-e MYSQL_LOG_CONSOLE=true \
mysql/mysql-server:8.0.32 \
--bind-address=0.0.0.0 \
--port=3306 \
--log-bin=binlog \
--gtid_mode=ON \
--enforce_gtid_consistency=ON \
--log_replica_updates=ON \
--binlog_format=ROW
docker run -itd --network host --name wescale \
-p 15306:15306 \
-w /vt/examples/wesql-server \
-e MYSQL_ROOT_USER=root \
-e MYSQL_ROOT_PASSWORD=passwd \
-e MYSQL_PORT=3306 \
-e MYSQL_HOST=127.0.0.1 \
${{ env.WESCALE_IMAGE }} \
/vt/examples/wesql-server/init_single_node_cluster.sh
- name: Wait for MySQL port
run: |
for i in {1..60}; do
if nc -z localhost 15306; then
echo "MySQL port 15306 is ready!"
exit 0
fi
echo "Waiting for MySQL port 15306..."
sleep 5
done
echo "Timeout waiting for MySQL port 15306"
exit 1
- name: Create Branch On Target Cluster
run: |
mysql -h127.0.0.1 -P15306 -e "Branch create with (
'source_host'='${{ env.SOURCE_HOST }}',
'source_port'='${{ env.SOURCE_PORT }}',
'source_user'='${{ env.SOURCE_USER }}',
'source_password'='${{ env.SOURCE_PASSWORD }}',
'include_databases'='${{ env.INCLUDE_DATABASES }}',
'exclude_databases'='${{ env.EXCLUDE_DATABASES }}'
);"
mysql -h127.0.0.1 -P15306 -e "Branch show"
- name: Checkout Repository
uses: actions/checkout@v3

- name: Create MySQL Branch
uses: wesql/mysql-branch-creation-action@v1
with:
source_host: '47.93.127.119'
source_port: '15306' # Optional
source_user: 'root' # Optional
include_databases: '*' # Optional
exclude_databases: 'information_schema,mysql,performance_schema,sys' # Optional
wescale_image: 'apecloud/apecloud-mysql-scale:0.3.8' # Optional
secrets:
source_password: ${{ secrets.source_password }}

- name: Do Your Schema Migration
run: |
Expand Down

0 comments on commit 081c2b1

Please sign in to comment.