CD Pipeline #3
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: CD Pipeline | |
| on: | |
| workflow_run: | |
| workflows: ["CI Pipeline"] | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| deploy-backend: | |
| name: Deploy Backend to Azure | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| - 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: Setup .NET 8 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Publish backend | |
| run: | | |
| cd backend | |
| dotnet publish -c Release -o publish | |
| - name: Deploy to Azure App Service | |
| uses: azure/webapps-deploy@v2 | |
| with: | |
| app-name: ${{ secrets.AZURE_APPSERVICE_NAME }} | |
| package: backend/publish | |
| deploy-frontend: | |
| name: Deploy Frontend to Azure | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| - 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: Setup Node.js 18 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies and build | |
| run: | | |
| cd frontend | |
| npm install --prefer-offline --no-audit --no-fund | |
| npm run build | |
| - name: Deploy to Azure Static Web Apps | |
| uses: azure/static-web-apps-deploy@v1 | |
| with: | |
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_DEPLOYMENT_TOKEN }} | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| action: "upload" | |
| app_location: "frontend/build" | |
| output_location: "" | |
| skip_app_build: true |