From 2cf22f6b06f242384a4b32167431abbebdf74435 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Wed, 19 Jul 2023 11:56:34 +0800 Subject: [PATCH] init --- .github/workflows/create-test.yml | 6 ++--- .github/workflows/init.yml | 39 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/init.yml diff --git a/.github/workflows/create-test.yml b/.github/workflows/create-test.yml index 9ec0282..95dc16b 100644 --- a/.github/workflows/create-test.yml +++ b/.github/workflows/create-test.yml @@ -8,7 +8,7 @@ on: jobs: setup: runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 5 steps: - name: Checkout uses: actions/checkout@v3 @@ -30,13 +30,13 @@ jobs: ticloud cluster delete -p 1372813089447741295 -c $id --force; done - connect-test: + create-test: needs: setup strategy: matrix: region: [ us-east-1, us-west-2, ap-northeast-1, ap-southeast-1, eu-central-1 ] runs-on: ubuntu-latest - timeout-minutes: 15 + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/init.yml b/.github/workflows/init.yml new file mode 100644 index 0000000..8cccb47 --- /dev/null +++ b/.github/workflows/init.yml @@ -0,0 +1,39 @@ +name: Init + +on: + pull_request: + +jobs: + setup: + strategy: + matrix: + region: [ us-east-1, us-west-2, ap-northeast-1, ap-southeast-1, eu-central-1 ] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up ticloud + uses: tidbcloud/setup-tidbcloud-cli@v0 + with: + api_public_key: oHloc6bC + api_private_key: aba07d40-7f6d-4c2c-8d6e-311639fd6c11 + + - name: Create cluster + run: | + PROJECT_ID=1372813089454311307 + ticloud cluster create -p $PROJECT_ID --cluster-name ${{ matrix.region }} --cloud-provider AWS -r ${{ matrix.region }} --root-password ${{ secrets.TIDB_CLOUD_PASSWORD }} --cluster-type SERVERLESS > ${{ matrix.region }} + cat ${{ matrix.region }} + ticloud cluster get -p $PROJECT_ID -c `cat ${{ matrix.region }} | sed 's/[^0-9]//g'` > ${{ matrix.region }} + cat ${{ matrix.region }} + echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_ENV + echo "CLUSTER_ID=`echo $(jq '.id' ${{ matrix.region }}) | sed 's/"//g'`" >> $GITHUB_ENV + echo "CLUSTER_USER=$(jq '.status.connection_strings.default_user' ${{ matrix.region }})" >> $GITHUB_ENV + echo "CLUSTER_HOST=$(jq '.status.connection_strings.standard.host' ${{ matrix.region }})" >> $GITHUB_ENV + + - name: Create branch + run: | + ticloud branch create -c ${{ env.CLUSTER_ID }} --branch-name ${{ matrix.region }} > ${{ matrix.region }} + cat ${{ matrix.region }} + ticloud branch get -c ${{ env.CLUSTER_ID }} -b `cat ${{ matrix.region }} | grep -o 'bran-[a-zA-Z0-9]*'` > ${{ matrix.region }} + cat ${{ matrix.region }}