-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcbd40b
commit a4e4c98
Showing
1 changed file
with
34 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
|
||
|