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.

70 lines
2.3 KiB

  1. name: "Build and push image"
  2. description: "Builds and pushes an image to a registry"
  3. inputs:
  4. service:
  5. description: "Service to build"
  6. required: true
  7. registry_host:
  8. description: "Image registry host e.g. myacr.azureacr.io"
  9. required: true
  10. registry_endpoint:
  11. description: "Image registry repo e.g. myacr.azureacr.io/eshop"
  12. required: true
  13. image_name:
  14. description: "Name of image"
  15. required: true
  16. registry_username:
  17. description: "Registry username"
  18. required: true
  19. registry_password:
  20. description: "Registry password"
  21. required: true
  22. runs:
  23. using: "composite"
  24. steps:
  25. - name: Enable experimental features for the Docker daemon and CLI
  26. shell: bash
  27. run: |
  28. echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json
  29. mkdir -p ~/.docker
  30. echo $'{\n "experimental": "enabled"\n}' | sudo tee ~/.docker/config.json
  31. sudo service docker restart
  32. docker version -f '{{.Client.Experimental}}'
  33. docker version -f '{{.Server.Experimental}}'
  34. - name: Login to Container Registry
  35. uses: docker/login-action@v1
  36. with:
  37. registry: ${{ inputs.registry_host }}
  38. username: ${{ inputs.registry_username }}
  39. password: ${{ inputs.registry_password }}
  40. - name: Set branch name as env variable
  41. run: |
  42. currentbranch=$(echo ${GITHUB_REF##*/})
  43. echo "running on $currentbranch"
  44. echo "BRANCH=$currentbranch" >> $GITHUB_ENV
  45. shell: bash
  46. - name: Compose build ${{ inputs.service }}
  47. shell: bash
  48. run: sudo -E docker-compose build ${{ inputs.service }}
  49. working-directory: ./src
  50. env:
  51. TAG: ${{ env.BRANCH }}
  52. REGISTRY: ${{ inputs.registry_endpoint }}
  53. - name: Compose push ${{ inputs.service }}
  54. shell: bash
  55. run: sudo -E docker-compose push ${{ inputs.service }}
  56. working-directory: ./src
  57. env:
  58. TAG: ${{ env.BRANCH }}
  59. REGISTRY: ${{ inputs.registry_endpoint }}
  60. - name: Create multiarch manifest
  61. shell: bash
  62. run: |
  63. docker --config ~/.docker manifest create ${{ inputs.registry_endpoint }}/${{ inputs.image_name }}:${{ env.BRANCH }} ${{ inputs.registry_endpoint }}/${{ inputs.image_name }}:linux-${{ env.BRANCH }}
  64. docker --config ~/.docker manifest push ${{ inputs.registry_endpoint }}/${{ inputs.image_name }}:${{ env.BRANCH }}