From 9e7988fb2998ec3642f3b44b504c959d62daa2be Mon Sep 17 00:00:00 2001 From: ThrRip Date: Tue, 7 Nov 2023 13:59:35 +0800 Subject: [PATCH] admin: Initialize workspace --- .github/workflows/build-deploy-[all].yml | 6 +- .github/workflows/build-deploy-admin.yml | 18 +++++ .github/workflows/build-deploy-home.yml | 1 + .github/workflows/build-deploy.yml | 18 +++++ .gitignore | 3 + .idea/dictionaries/thrrip.xml | 1 + .run/build_admin.run.xml | 12 ++++ .run/dev_admin.run.xml | 12 ++++ .run/preview_admin.run.xml | 12 ++++ package.json | 5 +- packages/admin/app.config.ts | 1 + packages/admin/ecosystem.config.js | 15 ++++ packages/admin/nuxt.config.ts | 46 ++++++++++++ packages/admin/package.json | 21 ++++++ packages/admin/tailwind.config.js | 1 + pnpm-lock.yaml | 92 +++++++++++++++++++++++- 16 files changed, 260 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build-deploy-admin.yml create mode 100644 .run/build_admin.run.xml create mode 100644 .run/dev_admin.run.xml create mode 100644 .run/preview_admin.run.xml create mode 100644 packages/admin/app.config.ts create mode 100644 packages/admin/ecosystem.config.js create mode 100644 packages/admin/nuxt.config.ts create mode 100644 packages/admin/package.json create mode 100644 packages/admin/tailwind.config.js diff --git a/.github/workflows/build-deploy-[all].yml b/.github/workflows/build-deploy-[all].yml index 34a4b18..920eee4 100644 --- a/.github/workflows/build-deploy-[all].yml +++ b/.github/workflows/build-deploy-[all].yml @@ -17,7 +17,11 @@ jobs: name: Build & Deploy / ${{ matrix.package }} strategy: matrix: - package: [home] + include: + - package: home + package_cap: HOME + - package: admin + package_cap: ADMIN uses: ./.github/workflows/build-deploy.yml with: package: ${{ matrix.package }} diff --git a/.github/workflows/build-deploy-admin.yml b/.github/workflows/build-deploy-admin.yml new file mode 100644 index 0000000..baa04c9 --- /dev/null +++ b/.github/workflows/build-deploy-admin.yml @@ -0,0 +1,18 @@ +name: Build & Deploy / admin +run-name: Build & Deploy (${{ github.ref_name }}/admin) + +on: + push: + paths: + - 'packages/admin/**' + +concurrency: build-deploy-admin-${{ github.ref }} + +jobs: + build-deploy-admin: + name: Build & Deploy + uses: ./.github/workflows/build-deploy.yml + with: + package: admin + package_cap: ADMIN + secrets: inherit diff --git a/.github/workflows/build-deploy-home.yml b/.github/workflows/build-deploy-home.yml index 2d84f61..3c67027 100644 --- a/.github/workflows/build-deploy-home.yml +++ b/.github/workflows/build-deploy-home.yml @@ -14,4 +14,5 @@ jobs: uses: ./.github/workflows/build-deploy.yml with: package: home + package_cap: HOME secrets: inherit diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 96a9129..d4dc8cc 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -4,6 +4,9 @@ on: package: required: true type: string + package_cap: + required: true + type: string secrets: PROD_CLOUD_SSH_URI: required: true @@ -15,6 +18,8 @@ on: required: true PROD_CLOUD_PROJECT_ROOT: required: true + PROD_HOME_PM2_CONF_ENV: + PROD_ADMIN_PM2_CONF_ENV: jobs: build: @@ -42,6 +47,19 @@ jobs: run: pnpm -F ${{ inputs.package }} install - name: Build standalone server run: 'pnpm run build:${{ inputs.package }}' + - name: Replace environment variables + run: | + [ -z "${{ secrets[format('PROD_{0}_PM2_CONF_ENV', inputs.package_cap)] }}" ] || ( + echo "${{ secrets[format('PROD_{0}_PM2_CONF_ENV', inputs.package_cap)] }}" | + awk ' + /env: {/,/}/ { + if (/env: {/ || /}/) print; + while((getline < "/dev/stdin") > 0) print; + next + } + { print } + ' packages/${{ inputs.package }}/ecosystem.config.js + ) - name: Package the build run: | cd packages/${{ inputs.package }} diff --git a/.gitignore b/.gitignore index cf53a67..efabecb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ !.idea/jsLinters/ !.idea/icon.svg +### Dotenv +.env + ### Node.js # Logs *.log* diff --git a/.idea/dictionaries/thrrip.xml b/.idea/dictionaries/thrrip.xml index e2cf3d2..9cd599a 100644 --- a/.idea/dictionaries/thrrip.xml +++ b/.idea/dictionaries/thrrip.xml @@ -6,6 +6,7 @@ bilibili dscreen fortawesome + getline nuxtjs shopt webmanifest diff --git a/.run/build_admin.run.xml b/.run/build_admin.run.xml new file mode 100644 index 0000000..f6ec0fd --- /dev/null +++ b/.run/build_admin.run.xml @@ -0,0 +1,12 @@ + + + + + +