main-prod.yml file updated - included environment section #24
This file contains hidden or 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: Ticketify CI-CD | |
| on: | |
| push: | |
| branches: ['main'] | |
| pull_request: | |
| branches: ['main'] | |
| workflow_dispatch: | |
| env: | |
| AZURE_WEBAPP_NAME: ticketifyne | |
| DOTNET_VERSION: '9.0.x' | |
| BUILD_OUTPUT: './publish_output' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Setup .net | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{env.DOTNET_VERSION}} | |
| - name: Restore dependencies | |
| run: dotnet restore ./Ticketify.sln | |
| - name: Build | |
| run: dotnet build ./API/API.csproj --configuration Release --no-restore | |
| - name: Test | |
| run: dotnet test ./Ticketify.sln --configuration Release --verbosity normal | |
| # clean the API output before publishing (avoid leftover test artifacts) | |
| - name: Clean API publish output | |
| run: rm -rf ${{env.BUILD_OUTPUT}} | |
| - name: Publish | |
| run: dotnet publish ./API/API.csproj -c Release -o ${{env.BUILD_OUTPUT}} --no-build | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dotnet-app | |
| path: ${{env.BUILD_OUTPUT}} | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dotnet-app | |
| path: ${{env.BUILD_OUTPUT}} | |
| - name: Azure login | |
| uses: azure/login@v2 | |
| with: | |
| creds: ${{secrets.AZURE_CREDENTIALS}} | |
| - name: Deploy to azure web app | |
| uses: azure/webapps-deploy@v3 | |
| with: | |
| app-name: ${{env.AZURE_WEBAPP_NAME}} | |
| package: ${{env.BUILD_OUTPUT}} |