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.

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