working with github output 2 #37
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
| # This workflow will build a .NET project | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
| name: Deployment Workflow | |
| on: | |
| push: | |
| branches: [ "main", "dev"] | |
| pull_request: | |
| branches: [ "main" ] | |
| types: | |
| - opened | |
| - closed | |
| - edited | |
| env: | |
| ASPNETCORE_ENVIRONMENT: Development | |
| JwtTokenOptions__RefreshTokenExpiryMinutes: 10080 | |
| JwtTokenOptions__Issuer: eCommerceApi | |
| JwtTokenOptions__ExpiryMinutes: 60 | |
| JwtTokenOptions__Audience: eCommerceClient | |
| Serilog__Using__0: Serilog.Sinks.MSSqlServer | |
| Serilog__Using__1: Serilog.Sinks.Seq | |
| Serilog__Using__2: Serilog.Sinks.Debug | |
| Serilog__Enrich__0: FromLogContext | |
| Serilog__Enrich__1: WithThreadId | |
| Serilog__Enrich__2: WithMachineName | |
| Serilog__Properties__Application: ECommerceApi | |
| Serilog__WriteTo__0__Name: MSSqlServer | |
| Serilog__WriteTo__0__Args__tableName: Logs | |
| Serilog__WriteTo__0__Args__autoCreateSqlTable: true | |
| Serilog__WriteTo__0__Args__batchPostingLimit: 200 | |
| Serilog__WriteTo__0__Args__period: 00:00:10 | |
| Serilog__WriteTo__1__Name: Seq | |
| Serilog__WriteTo__1__Args__serverUrl: http://host.docker.internal:5341 | |
| Serilog__WriteTo__2__Name: Debug | |
| Serilog__MinimumLevel__Default: Debug | |
| Serilog__MinimumLevel__Override__Microsoft.AspNetCore: Debug | |
| Serilog__MinimumLevel__Override__Microsoft.EntityFrameworkCore: Debug | |
| # secrets | |
| ASPNETCORE_URLS: ${{ secrets.ASPNETCORE_URLS }} | |
| JwtTokenOptions__SecretKey: ${{ secrets.JwtTokenOptions__SecretKey }} | |
| Authentication__Google__ClientSecret: ${{ secrets.Authentication__Google__ClientSecret }} | |
| Authentication__Google__ClientId: ${{ secrets.Authentication__Google__ClientId }} | |
| REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }} | |
| REDIS_PORT: ${{ secrets.REDIS_PORT }} | |
| SQL_PORT: ${{ vars.SQL_PORT }} | |
| SQL_PASSWORD: ${{ vars.SQL_PASSWORD }} | |
| API_PORT: ${{ vars.API_PORT }} | |
| jobs: | |
| build-test: | |
| # continue-on-error: true | |
| strategy: | |
| matrix: | |
| dotnet-version: ["8.0.x", "9.0.x", "10.0.x"] | |
| operating-system: ["ubuntu-latest", "windows-latest"] | |
| exclude: | |
| - operating-system: "windows-latest" | |
| runs-on: ${{ matrix.operating-system }} | |
| container: | |
| image: mcr.microsoft.com/dotnet/sdk:10.0 | |
| environment: staging | |
| services: | |
| sql: | |
| image: mcr.microsoft.com/mssql/server:2022-latest | |
| ports: | |
| - 1433:1433 | |
| env: | |
| ACCEPT_EULA: Y | |
| MSSQL_SA_PASSWORD: ${{ secrets.SQL_PASSWORD }} | |
| volumes: | |
| - sql-data:/var/opt/mssql | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 6379:6379 | |
| volumes: | |
| - redis-data:/data | |
| env: | |
| REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }} | |
| entrypoint: /bin/sh | |
| command: -c 'exec redis-server --requirepass "$REDIS_PASSWORD" --appendonly yes' | |
| steps: | |
| - name: Get Code | |
| uses: actions/checkout@v4 | |
| - name: Get & Cache Dependencies | |
| id: deps | |
| uses: ./.github/actions/cache-deps | |
| with: | |
| cache-disable: 'true' | |
| - name: Build | |
| run: dotnet build ./eCommerceSolution.slnx -c Release --no-restore | |
| - name: Test | |
| run: dotnet test ./eCommerceSolution.slnx -c Release --no-build --verbosity normal | |
| - name: Job report | |
| run: echo "cache disabled? ${{ steps.deps.outputs.cache-used }}" | |
| build-publish: | |
| strategy: | |
| matrix: | |
| dotnet-version: ["8.0.x", "9.0.x", "10.0.x"] | |
| operating-system: ["ubuntu-latest", "windows-latest"] | |
| exclude: | |
| - operating-system: "windows-latest" | |
| runs-on: ${{ matrix.operating-system }} | |
| container: | |
| image: mcr.microsoft.com/dotnet/sdk:10.0 | |
| services: | |
| sql: | |
| image: mcr.microsoft.com/mssql/server:2022-latest | |
| ports: | |
| - 1433:1433 | |
| env: | |
| ACCEPT_EULA: Y | |
| MSSQL_SA_PASSWORD: ${{ secrets.SQL_PASSWORD }} | |
| volumes: | |
| - sql-data:/var/opt/mssql | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 3000:6379 | |
| volumes: | |
| - redis-data:/data | |
| env: | |
| REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }} | |
| entrypoint: /bin/sh | |
| command: -c 'exec redis-server --requirepass "$REDIS_PASSWORD" --appendonly yes' | |
| environment: production | |
| outputs: | |
| random-number: ${{ steps.publish.outputs.random-num }} | |
| steps: | |
| - name: Get Code | |
| uses: actions/checkout@v4 | |
| - name: Get & Cache Dependencies | |
| id: deps | |
| uses: ./.github/actions/cache-deps | |
| - name: Build for publish | |
| id: publish | |
| run: | | |
| dotnet publish ./src/eCommerce.Api -c Release -o ./publish | |
| echo "random-num=10" >> "$GITHUB_OUTPUT" | |
| - name: Uploading Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: publish-artifacts | |
| path: ./publish | |
| - name: Job report | |
| run: echo "cache disabled? ${{ steps.deps.outputs.cache-used }}" | |
| deploy: | |
| needs: [build-test, build-publish] | |
| uses: ./.github/workflows/reusable-deploy.yml | |
| with: | |
| artifact-name: "./publish" | |
| deploy-result: | |
| needs: deploy | |
| runs-on: ubuntu-latest | |
| environment: production | |
| steps: | |
| - name: output deploy result | |
| run: echo "Deployment is ${{ needs.deploy.outputs.deploy-result }}" | |
| workflow-report: | |
| needs: deploy | |
| if: failure() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Output information | |
| run: | | |
| echo "something went wrong" | |
| echo "${{ toJson(github) }}" | |