build-public-image.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. name: "Infra: Image Testing: Deploy"
  2. on:
  3. workflow_dispatch:
  4. pull_request:
  5. types: ['labeled']
  6. jobs:
  7. build:
  8. if: ${{ github.event.label.name == 'status/image_testing' }}
  9. runs-on: ubuntu-latest
  10. steps:
  11. - uses: actions/checkout@v3
  12. with:
  13. ref: ${{ github.event.pull_request.head.sha }}
  14. - name: get branch name
  15. id: extract_branch
  16. run: |
  17. tag='${{ github.event.pull_request.number }}'
  18. echo "tag=${tag}" >> $GITHUB_OUTPUT
  19. - name: Set up JDK
  20. uses: actions/setup-java@v3
  21. with:
  22. java-version: '17'
  23. distribution: 'zulu'
  24. cache: 'maven'
  25. - name: Build
  26. id: build
  27. run: |
  28. ./mvnw -B -ntp versions:set -DnewVersion=$GITHUB_SHA
  29. ./mvnw -B -V -ntp clean package -Pprod -DskipTests
  30. export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
  31. echo "version=${VERSION}" >> $GITHUB_OUTPUT
  32. - name: Set up QEMU
  33. uses: docker/setup-qemu-action@v2
  34. - name: Set up Docker Buildx
  35. id: buildx
  36. uses: docker/setup-buildx-action@v2
  37. - name: Cache Docker layers
  38. uses: actions/cache@v3
  39. with:
  40. path: /tmp/.buildx-cache
  41. key: ${{ runner.os }}-buildx-${{ github.sha }}
  42. restore-keys: |
  43. ${{ runner.os }}-buildx-
  44. - name: Configure AWS credentials for Kafka-UI account
  45. uses: aws-actions/configure-aws-credentials@v3
  46. with:
  47. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  48. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  49. aws-region: us-east-1
  50. - name: Login to Amazon ECR
  51. id: login-ecr
  52. uses: aws-actions/amazon-ecr-login@v1
  53. with:
  54. registry-type: 'public'
  55. - name: Build and push
  56. id: docker_build_and_push
  57. uses: docker/build-push-action@v4
  58. with:
  59. builder: ${{ steps.buildx.outputs.name }}
  60. context: kafka-ui-api
  61. push: true
  62. tags: public.ecr.aws/provectus/kafka-ui-custom-build:${{ steps.extract_branch.outputs.tag }}
  63. build-args: |
  64. JAR_FILE=kafka-ui-api-${{ steps.build.outputs.version }}.jar
  65. cache-from: type=local,src=/tmp/.buildx-cache
  66. cache-to: type=local,dest=/tmp/.buildx-cache
  67. - name: make comment with private deployment link
  68. uses: peter-evans/create-or-update-comment@v3
  69. with:
  70. issue-number: ${{ github.event.pull_request.number }}
  71. body: |
  72. Image published at public.ecr.aws/provectus/kafka-ui-custom-build:${{ steps.extract_branch.outputs.tag }}
  73. outputs:
  74. tag: ${{ steps.extract_branch.outputs.tag }}