Update Dockerfile #6
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
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 | |
CONNECTION_STRING: ${{ secrets.SQL_CONNECTION_STRING }} # Add this to GitHub Secrets | |
steps: | |
# 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: ${{ 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 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 }} | |