From 93ac4d630f990c575c03d4b576e0218dc9b3db8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Tue, 14 Feb 2023 10:34:53 +0000 Subject: [PATCH 01/15] Create github-page-deploy.yml --- .github/workflows/github-page-deploy.yml | 82 ++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/github-page-deploy.yml diff --git a/.github/workflows/github-page-deploy.yml b/.github/workflows/github-page-deploy.yml new file mode 100644 index 0000000..8b33621 --- /dev/null +++ b/.github/workflows/github-page-deploy.yml @@ -0,0 +1,82 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy dev-branch content to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url } + + strategy: + matrix: + node-version: [16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + runs-on: [ self-hosted ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + name: Use Node.js ${{ matrix.node-version }} + with: + node-version: ${{ matrix.node-version }} + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: 7 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Use pnpm to build + run: pnpm run build + +# - name: post-build test +# run: pnpm test + + - name: Setup Pages + uses: actions/configure-pages@v2 + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: './dist' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 From 3a83739ccd1e78dbfe122665b25295726b9182cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Tue, 14 Feb 2023 10:35:36 +0000 Subject: [PATCH 02/15] Update github-page-deploy.yml --- .github/workflows/github-page-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-page-deploy.yml b/.github/workflows/github-page-deploy.yml index 8b33621..69bec06 100644 --- a/.github/workflows/github-page-deploy.yml +++ b/.github/workflows/github-page-deploy.yml @@ -24,7 +24,7 @@ jobs: deploy: environment: name: github-pages - url: ${{ steps.deployment.outputs.page_url } + url: ${{ steps.deployment.outputs.page_url }} strategy: matrix: From 33f481a1161add1751699a57215ada82ecb3a96c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Tue, 14 Feb 2023 10:39:00 +0000 Subject: [PATCH 03/15] Update github-page-deploy.yml --- .github/workflows/github-page-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-page-deploy.yml b/.github/workflows/github-page-deploy.yml index 69bec06..a4b4077 100644 --- a/.github/workflows/github-page-deploy.yml +++ b/.github/workflows/github-page-deploy.yml @@ -11,7 +11,7 @@ on: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: read + contents: write pages: write id-token: write From 077dd70225395ec6518acafc6f5c82c2264aeaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Tue, 14 Feb 2023 10:41:18 +0000 Subject: [PATCH 04/15] Update github-page-deploy.yml --- .github/workflows/github-page-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-page-deploy.yml b/.github/workflows/github-page-deploy.yml index a4b4077..69bec06 100644 --- a/.github/workflows/github-page-deploy.yml +++ b/.github/workflows/github-page-deploy.yml @@ -11,7 +11,7 @@ on: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: write + contents: read pages: write id-token: write From ac763dc92c9427a3145723460013f8bd773a8ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Tue, 14 Feb 2023 10:51:56 +0000 Subject: [PATCH 05/15] Update github-page-deploy.yml --- .github/workflows/github-page-deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-page-deploy.yml b/.github/workflows/github-page-deploy.yml index 69bec06..492ea14 100644 --- a/.github/workflows/github-page-deploy.yml +++ b/.github/workflows/github-page-deploy.yml @@ -76,7 +76,9 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: - path: './dist' + path: | + dist + dist/assets - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v1 From 02ce6d92395c4b93187199b48933f6903efe75eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Tue, 14 Feb 2023 10:55:03 +0000 Subject: [PATCH 06/15] Update github-page-deploy.yml --- .github/workflows/github-page-deploy.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/github-page-deploy.yml b/.github/workflows/github-page-deploy.yml index 492ea14..a855008 100644 --- a/.github/workflows/github-page-deploy.yml +++ b/.github/workflows/github-page-deploy.yml @@ -76,9 +76,7 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: - path: | - dist - dist/assets + path: dist - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v1 From 2f57ce58875b6684f82fa81a5870d534a7e8ee9f Mon Sep 17 00:00:00 2001 From: master1lan <278457198@qq.com> Date: Tue, 14 Feb 2023 19:24:43 +0800 Subject: [PATCH 07/15] change output dist path --- vite.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/vite.config.ts b/vite.config.ts index fbe7c0d..594cdb4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -71,6 +71,7 @@ export default defineConfig(({ mode }) => { build: { reportCompressedSize: false, minify: "esbuild", + outDir: "dist/eoefans-web", rollupOptions: { output: { manualChunks: { From c59712813b9a6a11dd7508cb4a7bf26bc423db33 Mon Sep 17 00:00:00 2001 From: master1lan <278457198@qq.com> Date: Tue, 14 Feb 2023 19:35:56 +0800 Subject: [PATCH 08/15] remove output dir to dist->eoefans-web --- vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 594cdb4..de09b26 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -71,7 +71,7 @@ export default defineConfig(({ mode }) => { build: { reportCompressedSize: false, minify: "esbuild", - outDir: "dist/eoefans-web", + assetsDir: "eoefans-web/assets", rollupOptions: { output: { manualChunks: { From 55e37a3e8860047cb1089b27ff7a2d819ea48018 Mon Sep 17 00:00:00 2001 From: master1lan Date: Tue, 14 Feb 2023 19:50:39 +0800 Subject: [PATCH 09/15] Update azure-staticwebapp.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整node版本 --- .github/workflows/azure-staticwebapp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/azure-staticwebapp.yml b/.github/workflows/azure-staticwebapp.yml index 614f006..d434111 100644 --- a/.github/workflows/azure-staticwebapp.yml +++ b/.github/workflows/azure-staticwebapp.yml @@ -43,7 +43,7 @@ jobs: strategy: matrix: - node-version: [16.x] + node-version: [18.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ name: Build and Deploy Job From 0b57b8038a66087c393bd1719366adac38912608 Mon Sep 17 00:00:00 2001 From: master1lan Date: Tue, 14 Feb 2023 19:51:34 +0800 Subject: [PATCH 10/15] Update codeql-analysis.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整node版本 --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c974952..fad22ee 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -36,7 +36,7 @@ jobs: language: [ 'javascript' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - node-version: [16.x] + node-version: [18.x] steps: - name: Checkout repository From 2f2f58b8dc7290d3b34e5296910d6ebd6e1bd56d Mon Sep 17 00:00:00 2001 From: master1lan Date: Tue, 14 Feb 2023 19:51:47 +0800 Subject: [PATCH 11/15] Update github-page-deploy.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整node版本 --- .github/workflows/github-page-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-page-deploy.yml b/.github/workflows/github-page-deploy.yml index a855008..1dce5c1 100644 --- a/.github/workflows/github-page-deploy.yml +++ b/.github/workflows/github-page-deploy.yml @@ -28,7 +28,7 @@ jobs: strategy: matrix: - node-version: [16.x] + node-version: [18.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ runs-on: [ self-hosted ] From 068f642ba0d66431ff435f388d45ae8b6f014a2f Mon Sep 17 00:00:00 2001 From: master1lan <278457198@qq.com> Date: Tue, 14 Feb 2023 19:53:54 +0800 Subject: [PATCH 12/15] copy output dist --- build.js | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 build.js diff --git a/build.js b/build.js new file mode 100644 index 0000000..a8d8acb --- /dev/null +++ b/build.js @@ -0,0 +1,10 @@ +import fs from "fs"; + +fs.cp( + "./dist/eoefans-web/assets", + "./dist/assets", + { recursive: true }, + (err) => { + console.log(err); + } +); diff --git a/package.json b/package.json index 85c7f30..d49c803 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build": "tsc && vite build && node build.js", "preview": "vite preview", "localdev": "vite --host 192.168.2.250" }, From 7fcc93946d171be0477b2872a6f86bdda1b6ce64 Mon Sep 17 00:00:00 2001 From: master1lan <278457198@qq.com> Date: Tue, 14 Feb 2023 20:06:25 +0800 Subject: [PATCH 13/15] =?UTF-8?q?=E8=BF=99=E6=AC=A1=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E6=B2=A1=E9=97=AE=E9=A2=98=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.js | 2 +- vite.config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.js b/build.js index a8d8acb..5bff936 100644 --- a/build.js +++ b/build.js @@ -1,7 +1,7 @@ import fs from "fs"; fs.cp( - "./dist/eoefans-web/assets", + "./dist/EOEFANS/eoefans-web/assets", "./dist/assets", { recursive: true }, (err) => { diff --git a/vite.config.ts b/vite.config.ts index de09b26..4fa89a7 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -71,7 +71,7 @@ export default defineConfig(({ mode }) => { build: { reportCompressedSize: false, minify: "esbuild", - assetsDir: "eoefans-web/assets", + assetsDir: "EOEFANS/eoefans-web/assets", rollupOptions: { output: { manualChunks: { From 15fb03b07f48701f493852d9a9c1c7d14c97bdf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Tue, 14 Feb 2023 12:13:07 +0000 Subject: [PATCH 14/15] Update and rename github-page-deploy.yml to dev-azure-staticwebapp.yml --- .github/workflows/dev-azure-staticwebapp.yml | 118 +++++++++++++++++++ .github/workflows/github-page-deploy.yml | 82 ------------- 2 files changed, 118 insertions(+), 82 deletions(-) create mode 100644 .github/workflows/dev-azure-staticwebapp.yml delete mode 100644 .github/workflows/github-page-deploy.yml diff --git a/.github/workflows/dev-azure-staticwebapp.yml b/.github/workflows/dev-azure-staticwebapp.yml new file mode 100644 index 0000000..384c862 --- /dev/null +++ b/.github/workflows/dev-azure-staticwebapp.yml @@ -0,0 +1,118 @@ +# This workflow will build and push a web application to an Azure Static Web App when you change your code. +# +# This workflow assumes you have already created the target Azure Static Web App. +# For instructions see https://docs.microsoft.com/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript +# +# To configure this workflow: +# +# 1. Set up a secret in your repository named AZURE_STATIC_WEB_APPS_API_TOKEN with the value of your Static Web Apps deployment token. +# For instructions on obtaining the deployment token see: https://docs.microsoft.com/azure/static-web-apps/deployment-token-management +# +# 3. Change the values for the APP_LOCATION, API_LOCATION and APP_ARTIFACT_LOCATION, AZURE_STATIC_WEB_APPS_API_TOKEN environment variables (below). +# For instructions on setting up the appropriate configuration values go to https://docs.microsoft.com/azure/static-web-apps/front-end-frameworks +name: Deploy DEV EOEFANS WEB to Azure Static Web Apps + +on: + push: + branches: [ "main" ] +# pull_request: +# types: [synchronize, closed] +# branches: [ "main" ] + +# Environment variables available to all jobs and steps in this workflow +env: + APP_LOCATION: "dist" # location of your client code + API_LOCATION: "" # location of your api source code - optional + APP_ARTIFACT_LOCATION: "" # location of client code build output + AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_DEV }} # secret containing deployment token for your static web app + SKIP_APP_BUILD: true + +permissions: + contents: read + +jobs: + build_and_deploy_job: + permissions: + contents: read # for actions/checkout to fetch code + pull-requests: write # for Azure/static-web-apps-deploy to comment on PRs + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: [ self-hosted, Linux ] + environment: + name: 'Production' +# url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + strategy: + matrix: + node-version: [18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + name: Build and Deploy Job + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + + - uses: actions/setup-node@v3 + name: Use Node.js ${{ matrix.node-version }} + with: + node-version: ${{ matrix.node-version }} + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: 7 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Use pnpm to build + run: pnpm run build + +# - name: post-build test +# run: pnpm test + + - name: Deploy build artifacts to Azure + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match you app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: ${{ env.APP_LOCATION }} + api_location: ${{ env.API_LOCATION }} + app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }} + skip_app_build: ${{ env.SKIP_APP_BUILD }} #comment this out to use azure oryx build + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + permissions: + contents: none + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: [ self-hosted, Linux ] + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app + action: "close" diff --git a/.github/workflows/github-page-deploy.yml b/.github/workflows/github-page-deploy.yml deleted file mode 100644 index 1dce5c1..0000000 --- a/.github/workflows/github-page-deploy.yml +++ /dev/null @@ -1,82 +0,0 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Deploy dev-branch content to Pages - -on: - # Runs on pushes targeting the default branch - push: - branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow one concurrent deployment -concurrency: - group: "pages" - cancel-in-progress: true - -jobs: - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - strategy: - matrix: - node-version: [18.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - runs-on: [ self-hosted ] - steps: - - name: Checkout - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - name: Use Node.js ${{ matrix.node-version }} - with: - node-version: ${{ matrix.node-version }} - - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: 7 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Use pnpm to build - run: pnpm run build - -# - name: post-build test -# run: pnpm test - - - name: Setup Pages - uses: actions/configure-pages@v2 - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - with: - path: dist - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 From 8d50922eb74ad9f03cc3dc13df3ed21a87c9f27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Tue, 14 Feb 2023 12:14:22 +0000 Subject: [PATCH 15/15] Update dev-azure-staticwebapp.yml --- .github/workflows/dev-azure-staticwebapp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev-azure-staticwebapp.yml b/.github/workflows/dev-azure-staticwebapp.yml index 384c862..f0e3a5c 100644 --- a/.github/workflows/dev-azure-staticwebapp.yml +++ b/.github/workflows/dev-azure-staticwebapp.yml @@ -38,7 +38,7 @@ jobs: if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') runs-on: [ self-hosted, Linux ] environment: - name: 'Production' + name: 'Development' # url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} strategy: