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
18 changes: 7 additions & 11 deletions .github/workflows/azure-back-end-03b2a610f.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
name: CI/CD for .NET app to Azure

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

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

# ✅ 手动触发部署
workflow_dispatch:
inputs:
environment:
Expand All @@ -26,8 +21,7 @@ env:

jobs:
ci-check:
# ✅ 只在 PR 阶段执行
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
runs-on: windows-latest
steps:
- name: Checkout code
Expand All @@ -45,10 +39,12 @@ jobs:
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

env:
DEPLOY_ENV: ${{ github.event.inputs.environment || 'Test' }}

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -66,22 +62,22 @@ jobs:

- name: Publish
run: |
$envName = if ("${{ github.event.inputs.environment }}" -eq "Production") { "Production" } else { "Test" }
$envName = "${{ env.DEPLOY_ENV }}"
dotnet publish ./dev-share-api/dev-share-api.csproj `
--configuration Release `
--output ./publish `
-p:EnvironmentName=$envName

- name: Deploy to Azure Web App - Production
if: github.event.inputs.environment == 'Production'
if: env.DEPLOY_ENV == '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 != 'Production'
if: env.DEPLOY_ENV != 'Production'
uses: azure/webapps-deploy@v3
with:
app-name: dev-share
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/azure-static-web-apps-green-moss-03b2a610f.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ name: CI/CD for Next.js app to Azure Web App
on:
pull_request:
branches: ['main']

push:
branches: ['main']

workflow_dispatch:
inputs:
environment:
Expand All @@ -23,7 +21,7 @@ env:

jobs:
ci-check:
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -34,7 +32,7 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install & Build (CI only)
- name: Install & Build (CI)
run: |
npm install
npm run build
Expand All @@ -43,6 +41,10 @@ jobs:
deploy:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

env:
DEPLOY_ENV: ${{ github.event.inputs.environment || 'Test' }}

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -55,7 +57,7 @@ jobs:
- name: Copy correct .env file
run: |
envFile=".env.test"
if [[ "${{ github.event.inputs.environment }}" == "Production" ]]; then
if [[ "${{ env.DEPLOY_ENV }}" == "Production" ]]; then
envFile=".env.production"
fi
cp ./dev-share-ui/$envFile ./dev-share-ui/.env
Expand All @@ -73,15 +75,15 @@ jobs:
if [ -d "public" ]; then cp -r public .next/standalone/; fi

- name: Deploy to Azure Web App - Production
if: github.event.inputs.environment == 'Production'
if: env.DEPLOY_ENV == '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 != 'Production'
if: env.DEPLOY_ENV != 'Production'
uses: azure/webapps-deploy@v3
with:
app-name: dev-share-ui-v1
Expand Down
Loading