Skip to content

Commit

Permalink
Update dotnet.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
raghav2404 authored Dec 12, 2024
1 parent bcbd40b commit a4e4c98
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET
name: .NET MVC CI/CD Pipeline

on:
push:
branches: [ "main" ]
branches:
- main # Trigger on push to 'main' branch
pull_request:
branches: [ "main" ]
branches:
- main # Trigger on pull request to 'main' branch

jobs:
build:

build-and-deploy:
runs-on: ubuntu-latest

env:
DOTNET_VERSION: 8.0
PUBLISH_DIR: ./publish
CONNECTION_STRING: ${{ secrets.SQL_CONNECTION_STRING }} # Add this to GitHub Secrets

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
# Step 1: Check out code
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up .NET
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: ${{ env.DOTNET_VERSION }}

# Step 3: Restore dependencies
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test

# Step 4: Build the solution
- name: Build the solution
run: dotnet build --configuration Release

# Step 5: Run tests (optional)
- name: Run tests
run: dotnet test --no-build --verbosity normal

# Step 6: Publish the application
- name: Publish application
run: dotnet publish --configuration Release --output ${{ env.PUBLISH_DIR }}


0 comments on commit a4e4c98

Please sign in to comment.