You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. name: ordering-api
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - dev
  7. paths:
  8. - src/BuildingBlocks/**
  9. - src/Services/Ordering/**
  10. - .github/workflows/ordering-api.yml
  11. pull_request:
  12. branches:
  13. - dev
  14. paths:
  15. - src/BuildingBlocks/**
  16. - src/Services/Ordering/**
  17. - .github/workflows/ordering-api.yml
  18. env:
  19. SERVICE: ordering-api
  20. IMAGE: ordering.api
  21. DOTNET_VERSION: 5.0.x
  22. jobs:
  23. BuildContainersForPR_Linux:
  24. runs-on: ubuntu-latest
  25. if: ${{ github.event_name == 'pull_request' }}
  26. steps:
  27. - name: 'Checkout Github Action'
  28. uses: actions/checkout@master
  29. - name: Setup dotnet
  30. uses: actions/setup-dotnet@v1
  31. with:
  32. dotnet-version: ${{ env.DOTNET_VERSION }}
  33. - name: Build and run unit tests
  34. run: |
  35. cd src
  36. dotnet restore "eShopOnContainers-ServicesAndWebApps.sln"
  37. cd Services/Ordering/Ordering.API
  38. dotnet build --no-restore
  39. cd -
  40. cd Services/Ordering/Ordering.UnitTests
  41. dotnet build --no-restore
  42. dotnet test --no-build -v=normal
  43. - name: Compose build ${{ env.SERVICE }}
  44. run: sudo -E docker-compose build ${{ env.SERVICE }}
  45. working-directory: ./src
  46. shell: bash
  47. env:
  48. TAG: ${{ env.BRANCH }}
  49. REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }}
  50. BuildLinux:
  51. runs-on: ubuntu-latest
  52. if: ${{ github.event_name != 'pull_request' }}
  53. steps:
  54. - name: 'Checkout Github Action'
  55. uses: actions/checkout@master
  56. - name: Setup dotnet
  57. uses: actions/setup-dotnet@v1
  58. with:
  59. dotnet-version: ${{ env.DOTNET_VERSION }}
  60. - name: Build and run unit tests
  61. run: |
  62. cd src
  63. dotnet restore "eShopOnContainers-ServicesAndWebApps.sln"
  64. cd Services/Ordering/Ordering.API
  65. dotnet build --no-restore
  66. cd -
  67. cd Services/Ordering/Ordering.UnitTests
  68. dotnet build --no-restore
  69. dotnet test --no-build -v=normal
  70. - name: Enable experimental features for the Docker daemon and CLI
  71. run: |
  72. echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json
  73. mkdir -p ~/.docker
  74. echo $'{\n "experimental": "enabled"\n}' | sudo tee ~/.docker/config.json
  75. sudo service docker restart
  76. docker version -f '{{.Client.Experimental}}'
  77. docker version -f '{{.Server.Experimental}}'
  78. - name: Login to Container Registry
  79. uses: docker/login-action@v1
  80. with:
  81. registry: ghcr.io
  82. username: ${{ github.repository_owner }}
  83. password: ${{ secrets.GITHUB_TOKEN }}
  84. - name: Pushing Image to Github Container Registry
  85. uses: docker/build-push-action@v2
  86. with:
  87. context: ./src
  88. version: latest
  89. file: ./src/Services/Ordering/Ordering.API/Dockerfile
  90. push: true
  91. tags: ghcr.io/variableclass/ordering.api:latest