From 6c59142a0303787db6896ec0d3234bd6783eb1b1 Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Fri, 1 Jul 2022 15:23:04 +0200 Subject: [PATCH 1/5] Add CLI deploy tests --- .github/workflows/tests-cli-deploy.yml | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/tests-cli-deploy.yml diff --git a/.github/workflows/tests-cli-deploy.yml b/.github/workflows/tests-cli-deploy.yml new file mode 100644 index 000000000000..7ad8acc5ac10 --- /dev/null +++ b/.github/workflows/tests-cli-deploy.yml @@ -0,0 +1,57 @@ +name: Tests CLI docusaurus deploy + +on: + pull_request: + branches: + - main + paths: + - packages/docusaurus/src/commands/deploy.ts + +# We queue those jobs on purpose to avoid race conditions +# Using a single static deploy branch: good enough +concurrency: + group: cli-deploy-singleton-group + cancel-in-progress: false + +permissions: + contents: read + +jobs: + test: + name: Tests + timeout-minutes: 5 + runs-on: ubuntu-latest + strategy: + matrix: + node: ['16.14', '16', '18'] + steps: + - name: Checkout + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3 + with: + node-version: ${{ matrix.node }} + cache: yarn + - name: Installation + run: yarn + + - name: Cleanup Deployment Git Branch + run: git push origin --delete ci-deploy-test-branch + # Normally that branch does not exist, but who knows what can happen + continue-on-error: true + + # We only test the deployment script, not the website build process + - name: Create artificial build dir + run: | + mkdir website/build + echo "CI CLI Deployment tests" > website/build/README.md + + # We run twice the same CLI deployment command + # The script has different code for new vs existing remote branch + - name: Test CLI deployment 1 (new branch) + run: DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build + - name: Test CLI deployment 2 (existing branch) + run: DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build + + - name: Cleanup Deployment Git Branch + run: git push origin --delete ci-deploy-test-branch From e92bd5d6198244e547ac71fc750bc69917a74889 Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Fri, 1 Jul 2022 15:28:50 +0200 Subject: [PATCH 2/5] comment --- packages/docusaurus/src/commands/deploy.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/docusaurus/src/commands/deploy.ts b/packages/docusaurus/src/commands/deploy.ts index 530d159b119b..cd1deae410a3 100644 --- a/packages/docusaurus/src/commands/deploy.ts +++ b/packages/docusaurus/src/commands/deploy.ts @@ -14,6 +14,8 @@ import {hasSSHProtocol, buildSshUrl, buildHttpsUrl} from '@docusaurus/utils'; import {loadContext, type LoadContextOptions} from '../server'; import {build} from './build'; +// Test temporary comment to trigger CI + export type DeployCLIOptions = Pick< LoadContextOptions, 'config' | 'locale' | 'outDir' From a4991582af2f3d8d2616c68081a57a458e1c5373 Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Fri, 1 Jul 2022 15:42:55 +0200 Subject: [PATCH 3/5] deploy fix --- .github/workflows/tests-cli-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-cli-deploy.yml b/.github/workflows/tests-cli-deploy.yml index 7ad8acc5ac10..46b87a3bde3a 100644 --- a/.github/workflows/tests-cli-deploy.yml +++ b/.github/workflows/tests-cli-deploy.yml @@ -49,9 +49,9 @@ jobs: # We run twice the same CLI deployment command # The script has different code for new vs existing remote branch - name: Test CLI deployment 1 (new branch) - run: DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build + run: GIT_USER=docusaurus-bot USE_SSH=false DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build - name: Test CLI deployment 2 (existing branch) - run: DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build + run: GIT_USER=docusaurus-bot USE_SSH=false DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build - name: Cleanup Deployment Git Branch run: git push origin --delete ci-deploy-test-branch From 68695e2106b9d43c986873cff9b38cc72859fda4 Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Fri, 1 Jul 2022 15:47:40 +0200 Subject: [PATCH 4/5] deploy fix --- .github/workflows/tests-cli-deploy.yml | 1 + packages/docusaurus/src/commands/deploy.ts | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests-cli-deploy.yml b/.github/workflows/tests-cli-deploy.yml index 46b87a3bde3a..45636200345f 100644 --- a/.github/workflows/tests-cli-deploy.yml +++ b/.github/workflows/tests-cli-deploy.yml @@ -6,6 +6,7 @@ on: - main paths: - packages/docusaurus/src/commands/deploy.ts + - .github/workflows/tests-cli-deploy.yml # We queue those jobs on purpose to avoid race conditions # Using a single static deploy branch: good enough diff --git a/packages/docusaurus/src/commands/deploy.ts b/packages/docusaurus/src/commands/deploy.ts index cd1deae410a3..530d159b119b 100644 --- a/packages/docusaurus/src/commands/deploy.ts +++ b/packages/docusaurus/src/commands/deploy.ts @@ -14,8 +14,6 @@ import {hasSSHProtocol, buildSshUrl, buildHttpsUrl} from '@docusaurus/utils'; import {loadContext, type LoadContextOptions} from '../server'; import {build} from './build'; -// Test temporary comment to trigger CI - export type DeployCLIOptions = Pick< LoadContextOptions, 'config' | 'locale' | 'outDir' From 1bdff13c319cbc2fb56b1634c28704c4f5cb1df1 Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Fri, 1 Jul 2022 16:13:57 +0200 Subject: [PATCH 5/5] try to remove permissions? --- .github/workflows/tests-cli-deploy.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests-cli-deploy.yml b/.github/workflows/tests-cli-deploy.yml index 45636200345f..d4c5b0cfba7d 100644 --- a/.github/workflows/tests-cli-deploy.yml +++ b/.github/workflows/tests-cli-deploy.yml @@ -14,9 +14,6 @@ concurrency: group: cli-deploy-singleton-group cancel-in-progress: false -permissions: - contents: read - jobs: test: name: Tests @@ -50,9 +47,9 @@ jobs: # We run twice the same CLI deployment command # The script has different code for new vs existing remote branch - name: Test CLI deployment 1 (new branch) - run: GIT_USER=docusaurus-bot USE_SSH=false DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build + run: DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build - name: Test CLI deployment 2 (existing branch) - run: GIT_USER=docusaurus-bot USE_SSH=false DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build + run: DEPLOYMENT_BRANCH=ci-deploy-test-branch yarn workspace website deploy --skip-build - name: Cleanup Deployment Git Branch run: git push origin --delete ci-deploy-test-branch