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.

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