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.

123 lines
3.5 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. name: basket-api
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - dev
  7. paths:
  8. - src/BuildingBlocks/**
  9. - src/Services/Basket/**
  10. - .github/workflows/basket-api.yml
  11. pull_request:
  12. branches:
  13. - dev
  14. paths:
  15. - src/BuildingBlocks/**
  16. - src/Services/Basket/**
  17. - .github/workflows/basket-api.yml
  18. env:
  19. SERVICE: basket-api
  20. IMAGE: basket.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/Basket/Basket.API
  38. dotnet build --no-restore
  39. cd -
  40. cd Services/Basket/Basket.UnitTests
  41. dotnet test
  42. - name: Compose build ${{ env.SERVICE }}
  43. run: sudo -E docker-compose build ${{ env.SERVICE }}
  44. working-directory: ./src
  45. shell: bash
  46. env:
  47. TAG: ${{ env.BRANCH }}
  48. REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }}
  49. BuildLinux:
  50. runs-on: ubuntu-latest
  51. if: ${{ github.event_name != 'pull_request' }}
  52. steps:
  53. - name: 'Checkout Github Action'
  54. uses: actions/checkout@master
  55. - name: Setup dotnet
  56. uses: actions/setup-dotnet@v1
  57. with:
  58. dotnet-version: ${{ env.DOTNET_VERSION }}
  59. - name: Build and run unit tests
  60. run: |
  61. cd src
  62. dotnet restore "eShopOnContainers-ServicesAndWebApps.sln"
  63. cd Services/Catalog/Catalog.API
  64. dotnet build --no-restore
  65. cd -
  66. cd Services/Catalog/Catalog.UnitTests
  67. dotnet test
  68. - name: Enable experimental features for the Docker daemon and CLI
  69. run: |
  70. echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json
  71. mkdir -p ~/.docker
  72. echo $'{\n "experimental": "enabled"\n}' | sudo tee ~/.docker/config.json
  73. sudo service docker restart
  74. docker version -f '{{.Client.Experimental}}'
  75. docker version -f '{{.Server.Experimental}}'
  76. - name: Login to Container Registry
  77. uses: docker/login-action@v1
  78. with:
  79. registry: ${{ secrets.REGISTRY_HOST }}
  80. username: ${{ secrets.USERNAME }}
  81. password: ${{ secrets.PASSWORD }}
  82. - name: Set branch name as env variable
  83. run: |
  84. currentbranch=$(echo ${GITHUB_REF##*/})
  85. echo "running on $currentbranch"
  86. echo "BRANCH=$currentbranch" >> $GITHUB_ENV
  87. shell: bash
  88. - name: Compose build ${{ env.SERVICE }}
  89. run: sudo -E docker-compose build ${{ env.SERVICE }}
  90. working-directory: ./src
  91. shell: bash
  92. env:
  93. TAG: ${{ env.BRANCH }}
  94. REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }}
  95. - name: Compose push ${{ env.SERVICE }}
  96. run: sudo -E docker-compose push ${{ env.SERVICE }}
  97. working-directory: ./src
  98. shell: bash
  99. env:
  100. TAG: ${{ env.BRANCH }}
  101. REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }}
  102. - name: Create multiarch manifest
  103. run: |
  104. docker --config ~/.docker manifest create ${{ secrets.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:${{ env.BRANCH }} ${{ secrets.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:linux-${{ env.BRANCH }}
  105. docker --config ~/.docker manifest push ${{ secrets.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:${{ env.BRANCH }}
  106. shell: bash