Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions .github/workflows/azure-back-end-03b2a610f.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
name: Build and deploy .NET app to Azure Web App
name: CI/CD for .NET app to Azure

on:
# ✅ PR 到 main:只执行 CI
pull_request:
branches: ['main']

# ✅ 合并 PR 到 main:自动部署到 Test
push:
branches:
- main
branches: ['main']

# ✅ 手动触发部署
workflow_dispatch:
inputs:
environment:
description: '选择部署环境'
description: 'Select deployment environment'
required: true
default: 'Test'
type: choice
Expand All @@ -19,11 +25,32 @@ env:
DOTNET_VERSION: '9.0.x'

jobs:
build-and-deploy:
ci-check:
# ✅ 只在 PR 阶段执行
if: github.event_name == 'pull_request'
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore dependencies
run: dotnet restore ./dev-share-api/dev-share-api.csproj

- name: Build
run: dotnet build ./dev-share-api/dev-share-api.csproj --configuration Release --no-restore

deploy:
# ✅ 仅在 main 合并 或 workflow_dispatch 时执行
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: windows-latest

steps:
- name: Checkout source
- name: Checkout code
uses: actions/checkout@v4

- name: Setup .NET SDK
Expand All @@ -46,15 +73,15 @@ jobs:
-p:EnvironmentName=$envName

- name: Deploy to Azure Web App - Production
if: ${{ github.event.inputs.environment == 'Production' }}
if: github.event.inputs.environment == 'Production'
uses: azure/webapps-deploy@v3
with:
app-name: prod-share-app
publish-profile: ${{ secrets.PROD_AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ./publish

- name: Deploy to Azure Web App - Test
if: ${{ github.event.inputs.environment == 'Test' }}
if: github.event.inputs.environment != 'Production'
uses: azure/webapps-deploy@v3
with:
app-name: dev-share
Expand Down
49 changes: 37 additions & 12 deletions .github/workflows/azure-static-web-apps-green-moss-03b2a610f.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: Build and deploy Next.js app to Azure Web App
name: CI/CD for Next.js app to Azure Web App

on:
pull_request:
branches: ['main']

push:
branches:
- main
branches: ['main']

workflow_dispatch:
inputs:
environment:
description: '选择部署环境'
description: 'Select deployment environment'
required: true
default: 'Test'
type: choice
Expand All @@ -19,44 +22,66 @@ env:
NODE_VERSION: "20.x"

jobs:
build-and-deploy:
ci-check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install & Build (CI only)
run: |
npm install
npm run build
working-directory: ./dev-share-ui

deploy:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout source
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Copy correct .env file
run: |
cp ./dev-share-ui/.env.${{ github.event.inputs.environment == 'Production' && 'production' || 'test' }} ./dev-share-ui/.env
envFile=".env.test"
if [[ "${{ github.event.inputs.environment }}" == "Production" ]]; then
envFile=".env.production"
fi
cp ./dev-share-ui/$envFile ./dev-share-ui/.env

- name: npm install and build
- name: Install & Build
run: |
npm install
npm run build
working-directory: ./dev-share-ui

- name: Copy static assets for standalone deployment
- name: Prepare static assets
run: |
cd dev-share-ui
cp -r .next/static .next/standalone/.next/
if [ -d "public" ]; then cp -r public .next/standalone/; fi

- name: Deploy to Azure Web App - Production
if: ${{ github.event.inputs.environment == 'Production' }}
if: github.event.inputs.environment == 'Production'
uses: azure/webapps-deploy@v3
with:
app-name: prod-share-ui
publish-profile: ${{ secrets.PROD_APP_PUBLISH_PROFILE }}
package: dev-share-ui/.next/standalone

- name: Deploy to Azure Web App - Test
if: ${{ github.event.inputs.environment == 'Test' }}
if: github.event.inputs.environment != 'Production'
uses: azure/webapps-deploy@v3
with:
app-name: dev-share-ui-v1
Expand Down
1 change: 1 addition & 0 deletions dev-share-api/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
}

[HttpGet("test")]
public async Task<IActionResult> test_v1()

Check warning on line 39 in dev-share-api/Controllers/ApiController.cs

View workflow job for this annotation

GitHub Actions / ci-check

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 39 in dev-share-api/Controllers/ApiController.cs

View workflow job for this annotation

GitHub Actions / ci-check

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{

var apiKey = _configuration["OpenAA:ApiKey"];
var endpoint = _configuration["OpenAA:Endpoint"];

Expand All @@ -50,7 +51,7 @@
}

[HttpPost("test3")]
public async Task<IActionResult> test3()

Check warning on line 54 in dev-share-api/Controllers/ApiController.cs

View workflow job for this annotation

GitHub Actions / ci-check

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 54 in dev-share-api/Controllers/ApiController.cs

View workflow job for this annotation

GitHub Actions / ci-check

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{

return Ok();
Expand Down Expand Up @@ -86,7 +87,7 @@
Console.WriteLine($"Extracting: {url}");

// 尝试 HtmlAgilityPack 抓取
var result = TryHtmlAgilityPack(url);

Check warning on line 90 in dev-share-api/Controllers/ApiController.cs

View workflow job for this annotation

GitHub Actions / ci-check

Possible null reference argument for parameter 'url' in 'string? ExtractController.TryHtmlAgilityPack(string url)'.

// 如果 HAP 解析失败(返回空),则使用 Playwright 模拟浏览器加载页面
if (string.IsNullOrWhiteSpace(result))
Expand Down
Loading