diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5bad524..2da38373 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: CI on: push: + branches: + - main branches: ["main"] jobs: @@ -10,7 +12,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - name: Set up .NET Core uses: actions/setup-dotnet@v4 @@ -25,14 +28,48 @@ jobs: - name: dotnet test run: dotnet test --configuration Release --no-restore - - name: dotnet publish + - name: Restore dependencies + run: dotnet restore --locked-mode + + - name: Run tests + run: dotnet test --configuration Release --no-restore + + - name: Publish application run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts - - uses: actions/upload-artifact@v4 + - name: Upload artifact + uses: actions/upload-artifact@v4 with: name: dometrain-artifact path: artifacts/ + deploy_dev: + name: Deploy Dev + runs-on: ubuntu-latest + needs: build + + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: dometrain-artifact + path: artifacts/ + + - name: Azure login + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Deploy to Azure App Service + uses: azure/webapps-deploy@v2 + with: + app-name: app-dometrain-github-actions-erisjakupi-dev + package: artifacts/ + name: dometrain-artifact + path: artifacts/ + deploy_dev: name: Deploy Dev runs-on: ubuntu-latest @@ -49,4 +86,4 @@ jobs: with: app-name: app-dometrain-github-actions-erisjakupi-dev package: artifacts/ - \ No newline at end of file +