From 081c2b1067a5f9cae2980b016c106f0fea22cfb3 Mon Sep 17 00:00:00 2001 From: earayu Date: Tue, 17 Dec 2024 12:40:15 +0800 Subject: [PATCH] chore: add branch_example.yml --- .github/workflows/branch_example.yml | 113 ++++----------------------- 1 file changed, 16 insertions(+), 97 deletions(-) diff --git a/.github/workflows/branch_example.yml b/.github/workflows/branch_example.yml index 802b2eb7ae..f26f7a3f50 100644 --- a/.github/workflows/branch_example.yml +++ b/.github/workflows/branch_example.yml @@ -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: |