From c096fa156b178da0c4e9442547bccedcdbcbc34d Mon Sep 17 00:00:00 2001 From: Whitewater Date: Tue, 28 Feb 2023 20:23:54 -0800 Subject: [PATCH] chore: add timed update workflow (#1214) --- .github/workflows/update-block-suite.yml | 71 ++++++++++++++++++++++++ docs/contributing/bump-blocksuite.md | 2 +- packages/data-center/src/utils/index.ts | 2 +- scripts/upgrade-blocksuite.sh | 11 ---- 4 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/update-block-suite.yml delete mode 100755 scripts/upgrade-blocksuite.sh diff --git a/.github/workflows/update-block-suite.yml b/.github/workflows/update-block-suite.yml new file mode 100644 index 0000000000..c0691d2c14 --- /dev/null +++ b/.github/workflows/update-block-suite.yml @@ -0,0 +1,71 @@ +name: Update block-suite version + +on: + schedule: + # At 02:00 UTC + - cron: '0 2 * * *' + workflow_dispatch: + +# Cancels all previous workflow runs for pull requests that have not completed. +# See https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # The concurrency group contains the workflow name and the branch name for + # pull requests or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + main: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use pnpm + uses: pnpm/action-setup@v2 + with: + version: 7 + + - name: Use Node.js 18 + # https://github.com/actions/setup-node + uses: actions/setup-node@v3 + with: + node-version: '18.X' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Get old version + id: old-version + run: | + PACKAGE_VERSION=$(cat apps/web/package.json | jq '.dependencies["@blocksuite/editor"]' | tr -d '"') + echo "old-version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT + + - name: Update block-suite version + run: pnpm update:core + + - name: Get new version + id: new-version + run: | + PACKAGE_VERSION=$(cat apps/web/package.json | jq '.dependencies["@blocksuite/editor"]' | tr -d '"') + echo "new-version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT + + # https://github.com/actions-js/push + - name: Commit push + uses: actions-js/push@master + with: + github_token: '${{ secrets.GITHUB_TOKEN }}' + message: 'chore: bump blocksuite from ${{ steps.old-version.outputs.old-version }} to ${{ steps.new-version.outputs.new-version }}' + force: true + branch: refs/heads/bot/bump-core + + # see https://github.com/repo-sync/pull-request + - name: Create Pull Request + uses: repo-sync/pull-request@v2 + with: + source_branch: bot/bump-core + pr_title: 'Bump blocksuite to ${{ steps.new-version.outputs.new-version }}' + pr_body: 'Please carefully check the editor functionality before merging the PR.' + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/contributing/bump-blocksuite.md b/docs/contributing/bump-blocksuite.md index 5558cbdd8a..9e0122ebf1 100644 --- a/docs/contributing/bump-blocksuite.md +++ b/docs/contributing/bump-blocksuite.md @@ -1,7 +1,7 @@ # Bump Blocksuite ```shell -./scripts/upgrade-blocksuite.sh +pnpm update:core ``` ## Understand the version number diff --git a/packages/data-center/src/utils/index.ts b/packages/data-center/src/utils/index.ts index e7d4087d87..ea31ce8e09 100644 --- a/packages/data-center/src/utils/index.ts +++ b/packages/data-center/src/utils/index.ts @@ -10,7 +10,7 @@ export const createBlocksuiteWorkspace = ( ) => { return new BlocksuiteWorkspace({ room: workspaceId, - defaultFlags: { enable_slash_menu: true }, + defaultFlags: {}, isSSR: typeof window === 'undefined', ...workspaceOption, }) diff --git a/scripts/upgrade-blocksuite.sh b/scripts/upgrade-blocksuite.sh deleted file mode 100755 index e197be434f..0000000000 --- a/scripts/upgrade-blocksuite.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -# Usage: -# ./scripts/upgrade-blocksuite.sh --latest -# ./scripts/upgrade-blocksuite.sh 0.4.0-20230209191848-0a912e3 - -if [ "$1" == "--latest" ]; then - pnpm up "@blocksuite/*" "!@blocksuite/icons" -r -i --latest -else - pnpm up "@blocksuite/*@${1}" "!@blocksuite/icons" -r -fi -