Skip to content

Commit

Permalink
Create dotnet.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
raghav2404 authored Dec 14, 2024
1 parent c9bec5b commit 03cbebd
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: .NET MVC CI/CD Pipeline

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

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

env:
DOTNET_VERSION: 8.0
PUBLISH_DIR: ./publish
IMAGE_NAME: ragh2404/demoMvcCore # Docker image name

steps:
# Step 1: Check out code
- name: Checkout code
uses: actions/checkout@v3

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

# Step 3: Restore dependencies
- name: Restore dependencies
run: dotnet restore

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

# Step 6: Build Docker Image
- name: Build Docker Image
run: |
docker build -t ${{ env.IMAGE_NAME }}:latest .
# Step 7: Log in to DockerHub (or your preferred registry)
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: raghav2404l
password: Rr24042000#Rr

# Step 8: Push Docker image to DockerHub
- name: Push Docker Image to Docker Hub
run: |
docker push ${{ env.IMAGE_NAME }}:latest

0 comments on commit 03cbebd

Please sign in to comment.