Create build.yml
This commit is contained in:
57
.github/workflows/build.yml
vendored
Normal file
57
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master # Change to your default branch if different
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: self-hosted # Ensure your self-hosted runner is configured
|
||||
environment: 'prod'
|
||||
steps:
|
||||
- name: Get Current User
|
||||
run: |
|
||||
$env:USERNAME
|
||||
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up .NET
|
||||
uses: actions/setup-dotnet@v2
|
||||
with:
|
||||
dotnet-version: '9.0' # Change to your required .NET version
|
||||
|
||||
- name: Restore .NET Dependencies
|
||||
run: dotnet restore ./HomeApi.sln
|
||||
|
||||
- name: Build .NET Project
|
||||
run: dotnet build --configuration Release ./HomeApi/HomeApi.csproj
|
||||
|
||||
- name: Publish .NET Project
|
||||
run: dotnet publish ./HomeApi/HomeApi.csproj --configuration Release --output ./output/dotnet
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dotnet-artifacts
|
||||
path: ./output/dotnet
|
||||
|
||||
deploy:
|
||||
runs-on: self-hosted # Ensure your self-hosted runner is configured
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- name: Download .NET Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: dotnet-artifacts
|
||||
path: ./output/dotnet
|
||||
|
||||
- name: Check Output Files
|
||||
run: |
|
||||
dir ./output/dotnet
|
||||
|
||||
- name: Copy .NET Publish Files to IIS Server
|
||||
run: |
|
||||
xcopy ".\output\dotnet\*" "C:\inetpub\applications\HomeApi" /s /i /y
|
||||
Reference in New Issue
Block a user