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.

163 lines
4.9 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
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. - master
  6. - dev
  7. - feature/github-actions
  8. paths:
  9. - src/BuildingBlocks/*
  10. - src/Services/Basket/*
  11. - .github/workflows/basket-api.yml
  12. pull_request:
  13. branches:
  14. - master
  15. - dev
  16. env:
  17. REGISTRY_ENDPOINT: borjasanes
  18. REGISTRY_HOST: docker.io
  19. SERVICE: basket-api
  20. IMAGE: basket.api
  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: ${{ env.REGISTRY_ENDPOINT }}
  35. BuildContainersForPR_Windows:
  36. runs-on: windows-2019
  37. if: ${{ false }}
  38. # if: ${{ github.event_name == 'pull_request' }}
  39. steps:
  40. - name: 'Checkout Github Action'
  41. uses: actions/checkout@master
  42. - name: Compose build ${{ env.SERVICE }}
  43. run: docker-compose build ${{ env.SERVICE }}
  44. working-directory: ./src
  45. shell: pwsh
  46. env:
  47. TAG: ${{ env.branch }}
  48. REGISTRY: ${{ env.REGISTRY_ENDPOINT }}
  49. PLATFORM: win
  50. NODE_IMAGE: stefanscherer/node-windows:10
  51. BuildLinux:
  52. runs-on: ubuntu-latest
  53. if: ${{ github.event_name != 'pull_request' }}
  54. steps:
  55. - name: 'Checkout Github Action'
  56. uses: actions/checkout@master
  57. - name: Login to Container Registry
  58. uses: docker/login-action@v1
  59. with:
  60. registry: ${{ env.REGISTRY_HOST }}
  61. username: ${{ secrets.USERNAME }}
  62. password: ${{ secrets.PASSWORD }}
  63. - name: Set branch name as env variable
  64. run: |
  65. currentbranch=$(echo ${GITHUB_REF##*/})
  66. echo "running on $currentbranch"
  67. echo "BRANCH=$currentbranch" >> $GITHUB_ENV
  68. shell: bash
  69. - name: Compose build ${{ env.SERVICE }}
  70. run: sudo -E docker-compose build ${{ env.SERVICE }}
  71. working-directory: ./src
  72. shell: bash
  73. env:
  74. TAG: ${{ env.BRANCH }}
  75. REGISTRY: ${{ env.REGISTRY_ENDPOINT }}
  76. - name: Compose push ${{ env.SERVICE }}
  77. run: sudo -E docker-compose push ${{ env.SERVICE }}
  78. working-directory: ./src
  79. shell: bash
  80. env:
  81. TAG: ${{ env.BRANCH }}
  82. REGISTRY: ${{ env.REGISTRY_ENDPOINT }}
  83. BuildWindows:
  84. runs-on: windows-2019
  85. if: ${{ false }}
  86. # if: ${{ github.event_name != 'pull_request' }}
  87. steps:
  88. - name: 'Checkout Github Action'
  89. uses: actions/checkout@master
  90. - name: Login to Container Registry
  91. uses: azure/docker-login@v1
  92. with:
  93. login-server: ${{ env.REGISTRY_HOST }}
  94. username: ${{ secrets.USERNAME }}
  95. password: ${{ secrets.PASSWORD }}
  96. - name: Set branch name as env variable
  97. shell: pwsh
  98. run: echo "BRANCH=$($env:GITHUB_REF.replace('refs/heads/', ''))" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  99. - name: Compose build ${{ env.SERVICE }}
  100. run: docker-compose build ${{ env.SERVICE }}
  101. working-directory: ./src
  102. shell: pwsh
  103. env:
  104. TAG: ${{ env.BRANCH }}
  105. REGISTRY: ${{ env.REGISTRY_ENDPOINT }}
  106. - name: Compose push ${{ env.SERVICE }}
  107. run: docker-compose push ${{ env.SERVICE }}'
  108. working-directory: ./src
  109. shell: pwsh
  110. env:
  111. TAG: ${{ env.BRANCH }}
  112. REGISTRY: ${{ env.REGISTRY_ENDPOINT }}
  113. BuildMultiarch:
  114. env:
  115. DOCKER_CONFIG: $HOME/.docker
  116. runs-on: ubuntu-latest
  117. needs:
  118. - BuildLinux
  119. if: ${{ github.event_name != 'pull_request' }}
  120. steps:
  121. - uses: actions/checkout@v2
  122. - name: Login to Container Registry
  123. uses: docker/login-action@v1
  124. with:
  125. registry: ${{ env.REGISTRY_HOST }}
  126. username: ${{ secrets.USERNAME }}
  127. password: ${{ secrets.PASSWORD }}
  128. - name: Set branch name as env variable
  129. run: |
  130. currentbranch=$(echo ${GITHUB_REF##*/})
  131. echo "running on $currentbranch"
  132. echo "BRANCH=$currentbranch" >> $GITHUB_ENV
  133. shell: bash
  134. - name: Create multiarch manifest
  135. run: |
  136. mkdir -p ~/.docker
  137. sed '$ s/.$//' $DOCKER_CONFIG/config.json > ~/.docker/config.json
  138. echo ',"experimental": "enabled" }' >> ~/.docker/config.json
  139. docker --config ~/.docker manifest create ${{ env.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:${{ env.BRANCH }} ${{ env.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:linux-${{ env.BRANCH }}
  140. docker --config ~/.docker manifest create ${{ env.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:latest ${{ env.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:linux-latest
  141. docker --config ~/.docker manifest push ${{ env.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:${{ env.BRANCH }}
  142. docker --config ~/.docker manifest push ${{ env.REGISTRY_ENDPOINT }}/${{ env.IMAGE }}:latest
  143. shell: bash