From 99978d530627e515e86ceeb4f0d0f8831f8724bd Mon Sep 17 00:00:00 2001 From: Adela Date: Thu, 22 May 2025 11:12:13 +0800 Subject: [PATCH 1/5] Delete .github/workflows/release.yml --- .github/workflows/release.yml | 109 ---------------------------------- 1 file changed, 109 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index b0e3cc6..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Rollout - -on: - push: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build app and upload - run: | - echo "Building..." - echo "Build done!" - echo "Uploading..." - echo "Upload done!" - deploy-to-test: - needs: build - runs-on: ubuntu-latest # use self-hosted machines if your Bytebase runs in internal networks. - environment: test - env: - BYTEBASE_URL: https://demo.bytebase.com - BYTEBASE_SERVICE_ACCOUNT: ci@service.bytebase.com - BYTEBASE_PROJECT: "projects/project-sample" - # The Bytebase rollout pipeline will deploy to 'test' and 'prod' environments. - # 'deploy-to-test' job rollouts the 'test' stage and 'deploy-to-prod' job rollouts the 'prod' stage. - BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test,instances/prod-sample-instance/databases/hr_prod" - FILE_PATTERN: "migrations/*.sql" - outputs: - bytebase-plan: ${{ steps.create-plan.outputs.plan }} - deployment-required: ${{ steps.create-plan.outputs.deployment-required }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Login to Bytebase - id: login - uses: bytebase/login-action@v1 - with: - bytebase-url: ${{ env.BYTEBASE_URL }} - service-key: ${{ env.BYTEBASE_SERVICE_ACCOUNT }} - service-secret: ${{secrets.BYTEBASE_SERVICE_ACCOUNT_SECRET}} # Please use secrets for sensitive data in production. - - name: Create release - id: create-release - uses: bytebase/create-release-action@v1 - with: - url: ${{ env.BYTEBASE_URL }} - token: ${{ steps.login.outputs.token }} - file-pattern: ${{ env.FILE_PATTERN }} - # fail the action if release checks report any error. - check-release: "FAIL_ON_ERROR" - project: ${{ env.BYTEBASE_PROJECT }} - targets: ${{ env.BYTEBASE_TARGETS }} - validate-only: false - - name: Create plan - id: create-plan - uses: bytebase/create-plan-from-release-action@v1 - with: - url: ${{ env.BYTEBASE_URL }} - token: ${{ steps.login.outputs.token }} - project: ${{ env.BYTEBASE_PROJECT }} - release: ${{ steps.create-release.outputs.release }} - targets: ${{ env.BYTEBASE_TARGETS }} - check-plan: "SKIP" - - name: Rollout - id: rollout - uses: bytebase/rollout-action@v2 - if: ${{ steps.create-plan.outputs.deployment-required == 'true' }} - with: - url: ${{ env.BYTEBASE_URL }} - token: ${{ steps.login.outputs.token }} - plan: ${{ steps.create-plan.outputs.plan }} - target-stage: environments/test # the stage environment. - - name: Deploy app - run: | - echo "Deploying app to test environment..." - echo "Deploy app to test environment done!" - deploy_to_prod: - needs: deploy-to-test - runs-on: ubuntu-latest - environment: prod - env: - BYTEBASE_URL: https://demo.bytebase.com - BYTEBASE_SERVICE_ACCOUNT: ci@service.bytebase.com - if: ${{ needs.deploy-to-test.outputs.deployment-required == 'true' }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Login to Bytebase - id: login - uses: bytebase/login-action@v1 - with: - bytebase-url: ${{ env.BYTEBASE_URL }} - service-key: ${{ env.BYTEBASE_SERVICE_ACCOUNT }} - service-secret: ${{secrets.BYTEBASE_SERVICE_ACCOUNT_SECRET}} # Please use secrets for sensitive data in production. - - name: Rollout - id: rollout - uses: bytebase/rollout-action@v2 - with: - url: ${{ env.BYTEBASE_URL }} - token: ${{ steps.login.outputs.token }} - plan: ${{ needs.deploy-to-test.outputs.bytebase-plan }} - target-stage: environments/prod # the stage environment. - - name: Deploy app - run: | - echo "Deploying app to prod environment..." - echo "Deploy app to prod environment done!" From da2d18526cc5a07bc26d9b6d3565a53a9e89d1d2 Mon Sep 17 00:00:00 2001 From: Adela Date: Thu, 22 May 2025 11:13:08 +0800 Subject: [PATCH 2/5] Delete .github/workflows/sql-review.yml --- .github/workflows/sql-review.yml | 74 -------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 .github/workflows/sql-review.yml diff --git a/.github/workflows/sql-review.yml b/.github/workflows/sql-review.yml deleted file mode 100644 index 59c0fbf..0000000 --- a/.github/workflows/sql-review.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: SQL review on pull request - -on: - pull_request: - branches: - - main - paths: - - "migrations/*.sql" - -jobs: - check-release-on-test: - permissions: - pull-requests: write # write permission required to allow the action writes the check results to the comment. - runs-on: ubuntu-latest # use self-hosted machines if your Bytebase runs in internal networks. - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # set GITHUB_TOKEN because the 'Check release' step needs it to comment the pull request with check results. - BYTEBASE_URL: https://demo.bytebase.com - BYTEBASE_SERVICE_ACCOUNT: ci@service.bytebase.com - BYTEBASE_PROJECT: "projects/project-sample" - BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test" - FILE_PATTERN: "migrations/*.sql" - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Login to Bytebase - id: login - uses: bytebase/login-action@v1 - with: - bytebase-url: ${{ env.BYTEBASE_URL }} - service-key: ${{ env.BYTEBASE_SERVICE_ACCOUNT }} - service-secret: ${{secrets.BYTEBASE_SERVICE_ACCOUNT_SECRET}} # Please use secrets for sensitive data in production. - - name: Check release - uses: bytebase/create-release-action@v1 - with: - url: ${{ env.BYTEBASE_URL }} - token: ${{ steps.login.outputs.token }} - file-pattern: ${{ env.FILE_PATTERN }} - # fail the action if release checks report any error. - check-release: "FAIL_ON_ERROR" - project: ${{ env.BYTEBASE_PROJECT }} - targets: ${{ env.BYTEBASE_TARGETS }} - validate-only: true - check-release-on-prod: - permissions: - pull-requests: write # write permission required to allow the action writes the check results to the comment. - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # set GITHUB_TOKEN because the 'Check release' step needs it to comment the pull request with check results. - BYTEBASE_URL: https://demo.bytebase.com - BYTEBASE_SERVICE_ACCOUNT: ci@service.bytebase.com - BYTEBASE_PROJECT: "projects/project-sample" - BYTEBASE_TARGETS: "instances/prod-sample-instance/databases/hr_prod" - FILE_PATTERN: "migrations/*.sql" - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Login to Bytebase - id: login - uses: bytebase/login-action@v1 - with: - bytebase-url: ${{ env.BYTEBASE_URL }} - service-key: ${{ env.BYTEBASE_SERVICE_ACCOUNT }} - service-secret: ${{secrets.BYTEBASE_SERVICE_ACCOUNT_SECRET}} # Please use secrets for sensitive data in production. - - name: Check release - uses: bytebase/create-release-action@v1 - with: - url: ${{ env.BYTEBASE_URL }} - token: ${{ steps.login.outputs.token }} - file-pattern: ${{ env.FILE_PATTERN }} - # fail the action if release checks report any error. - check-release: "FAIL_ON_ERROR" - project: ${{ env.BYTEBASE_PROJECT }} - targets: ${{ env.BYTEBASE_TARGETS }} - validate-only: true From acbe70ca2387829cf25ed79219cbe5a4f9228347 Mon Sep 17 00:00:00 2001 From: Adela Date: Thu, 22 May 2025 11:17:00 +0800 Subject: [PATCH 3/5] Delete migrations directory --- migrations/202503071616_create_ticket_table.sql | 4 ---- migrations/202503181018_ticket_table_add_date_column.sql | 1 - migrations/202503181054_1.sql | 1 - migrations/202503181055_2.sql | 1 - migrations/202504171429_1.sql | 3 --- migrations/202504171526_2.sql | 3 --- migrations/202504301754_1.sql | 3 --- 7 files changed, 16 deletions(-) delete mode 100644 migrations/202503071616_create_ticket_table.sql delete mode 100644 migrations/202503181018_ticket_table_add_date_column.sql delete mode 100644 migrations/202503181054_1.sql delete mode 100644 migrations/202503181055_2.sql delete mode 100644 migrations/202504171429_1.sql delete mode 100644 migrations/202504171526_2.sql delete mode 100644 migrations/202504301754_1.sql diff --git a/migrations/202503071616_create_ticket_table.sql b/migrations/202503071616_create_ticket_table.sql deleted file mode 100644 index 07c5f9d..0000000 --- a/migrations/202503071616_create_ticket_table.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE IF NOT EXISTS ticket ( - id int, - name text -); diff --git a/migrations/202503181018_ticket_table_add_date_column.sql b/migrations/202503181018_ticket_table_add_date_column.sql deleted file mode 100644 index 025d45f..0000000 --- a/migrations/202503181018_ticket_table_add_date_column.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE IF EXISTS ticket ADD IF NOT EXISTS release_date DATE; diff --git a/migrations/202503181054_1.sql b/migrations/202503181054_1.sql deleted file mode 100644 index ab290eb..0000000 --- a/migrations/202503181054_1.sql +++ /dev/null @@ -1 +0,0 @@ -select 1; diff --git a/migrations/202503181055_2.sql b/migrations/202503181055_2.sql deleted file mode 100644 index b403af1..0000000 --- a/migrations/202503181055_2.sql +++ /dev/null @@ -1 +0,0 @@ -select 2; diff --git a/migrations/202504171429_1.sql b/migrations/202504171429_1.sql deleted file mode 100644 index 89cfa57..0000000 --- a/migrations/202504171429_1.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE TABLE IF NOT EXISTS wer ( - id int -); \ No newline at end of file diff --git a/migrations/202504171526_2.sql b/migrations/202504171526_2.sql deleted file mode 100644 index 6cceccc..0000000 --- a/migrations/202504171526_2.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE TABLE IF NOT EXISTS oijoir ( - id int -); \ No newline at end of file diff --git a/migrations/202504301754_1.sql b/migrations/202504301754_1.sql deleted file mode 100644 index ca94e07..0000000 --- a/migrations/202504301754_1.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE TABLE IF NOT EXISTS geoiwjgoiwerjg ( - id int -); \ No newline at end of file From 332a62d8862b1546be20850879e45df2acd62e9b Mon Sep 17 00:00:00 2001 From: Adela Date: Thu, 22 May 2025 11:20:33 +0800 Subject: [PATCH 4/5] Update README.md --- README.md | 51 ++------------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 373e57d..b28fce7 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Modify the environment variables to match your setup. BYTEBASE_SERVICE_ACCOUNT_SECRET: ${{secrets.BYTEBASE_SERVICE_ACCOUNT_SECRET}} BYTEBASE_PROJECT: "projects/project-sample" BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test" # the database targets to check against. - FILE_PATTERN: "migrations/*.sql" # the glob pattern matching the migration files. + FILE_PATTERN: "migrations-semver/*.sql" # the glob pattern matching the migration files. ``` Set your service account password in the repository secrets setting with the name `BYTEBASE_SERVICE_ACCOUNT_SECRET`. @@ -52,7 +52,7 @@ You need to edit both deploy-to-test and deploy-to-prod jobs. # 'deploy_to_test' job rollouts the 'test' stage and 'deploy_to_prod' job rollouts the 'prod' stage. BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test,instances/prod-sample-instance/databases/hr_prod" BYTEBASE_TARGET_STAGE: environments/test - FILE_PATTERN: "migrations/*.sql" + FILE_PATTERN: "migrations-semver/*.sql" ``` In the repository environments setting, create two environments: "test" and "prod". In the "prod" environment setting, configure "Deployment protection rules", check "Required reviewers" and add reviewers in order to rollout the "prod" environment after approval. @@ -61,50 +61,3 @@ Set your service account password in the repository secrets setting with the nam > [!IMPORTANT] > The migration filename SHOULD comply to the naming scheme described in [bytebase-action](https://github.com/bytebase/bytebase/tree/main/action#global-flags) `--file-pattern` flag section. - -## Use javascript actions - -### How to configure sql-review.yml - -Copy [sql-review.yml](/.github/workflows/sql-review.yml) to your repository. - -Modify the environment variables to match your setup. - -```yml - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # set GITHUB_TOKEN because the 'Check release' step needs it to comment the pull request with check results. - BYTEBASE_URL: https://demo.bytebase.com - BYTEBASE_SERVICE_ACCOUNT: ci@service.bytebase.com - BYTEBASE_PROJECT: "projects/project-sample" - BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test" # the database targets to check against. - FILE_PATTERN: "migrations/*.sql" # the glob pattern matching the migration files. -``` - -Set your service account password in the repository secrets setting with the name `BYTEBASE_SERVICE_ACCOUNT_SECRET`. - -> [!IMPORTANT] -> The migration filename SHOULD comply to the naming scheme described in [bytebase-action](https://github.com/bytebase/bytebase/tree/main/action#global-flags) `--file-pattern` flag section. - -### How to configure release.yml - -Copy [release.yml](/.github/workflows/release.yml) to your repository. - -Modify the environment variables to match your setup. - -```yml - env: - BYTEBASE_URL: https://demo.bytebase.com - BYTEBASE_SERVICE_ACCOUNT: ci@service.bytebase.com - BYTEBASE_PROJECT: "projects/project-sample" - # The Bytebase rollout pipeline will deploy to 'test' and 'prod' environments. - # 'deploy_to_test' job rollouts the 'test' stage and 'deploy_to_prod' job rollouts the 'prod' stage. - BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test,instances/prod-sample-instance/databases/hr_prod" - FILE_PATTERN: "migrations/*.sql" # the glob pattern matching the migration files. -``` - -In the repository environments setting, create two environments: "test" and "prod". In the "prod" environment setting, configure "Deployment protection rules", check "Required reviewers" and add reviewers in order to rollout the "prod" environment after approval. - -Set your service account password in the repository secrets setting with the name `BYTEBASE_SERVICE_ACCOUNT_SECRET`. - -> [!IMPORTANT] -> The migration filename SHOULD comply to the naming scheme described in [bytebase-action](https://github.com/bytebase/bytebase/tree/main/action#global-flags) `--file-pattern` flag section. \ No newline at end of file From 4716eb71f06d54a189d4ae1759eb5ba154cf7fe8 Mon Sep 17 00:00:00 2001 From: Adela Date: Thu, 22 May 2025 11:22:01 +0800 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b28fce7..64c5e69 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ For GitHub flow, feature branches are merged into the main branch and the main b [release-action.yml](/.github/workflows/release-action.yml) builds the code and then for each environment migrate the databases and deploy the code. Using [environments with protection rules](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment#required-reviewers), it can deploy to the test environment automatically and push to the prod environment after approval. -## Use bytebase/bytebase-action (recommended) +## Use bytebase/bytebase-action The README of bytebase/bytebase-action can be found at [README](https://github.com/bytebase/bytebase/blob/main/action/README.md).