branch-deploy.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. name: "Infra: Feature Testing: Init env"
  2. on:
  3. workflow_dispatch:
  4. pull_request:
  5. types: ['labeled']
  6. jobs:
  7. build:
  8. if: ${{ github.event.label.name == 'status/feature_testing' || github.event.label.name == 'status/feature_testing_public' }}
  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='pr${{ github.event.pull_request.number }}'
  18. echo "tag=${tag}" >> $GITHUB_OUTPUT
  19. env:
  20. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  21. - name: Set up JDK
  22. uses: actions/setup-java@v3
  23. with:
  24. java-version: '17'
  25. distribution: 'zulu'
  26. cache: 'maven'
  27. - name: Build
  28. id: build
  29. run: |
  30. ./mvnw -B -ntp versions:set -DnewVersion=$GITHUB_SHA
  31. ./mvnw -B -V -ntp clean package -Pprod -DskipTests
  32. export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
  33. echo "version=${VERSION}" >> $GITHUB_OUTPUT
  34. - name: Set up QEMU
  35. uses: docker/setup-qemu-action@v2
  36. - name: Set up Docker Buildx
  37. id: buildx
  38. uses: docker/setup-buildx-action@v2
  39. - name: Cache Docker layers
  40. uses: actions/cache@v3
  41. with:
  42. path: /tmp/.buildx-cache
  43. key: ${{ runner.os }}-buildx-${{ github.sha }}
  44. restore-keys: |
  45. ${{ runner.os }}-buildx-
  46. - name: Configure AWS credentials for Kafka-UI account
  47. uses: aws-actions/configure-aws-credentials@v3
  48. with:
  49. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  50. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  51. aws-region: eu-central-1
  52. - name: Login to Amazon ECR
  53. id: login-ecr
  54. uses: aws-actions/amazon-ecr-login@v1
  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: 297478128798.dkr.ecr.eu-central-1.amazonaws.com/kafka-ui:${{ 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. outputs:
  68. tag: ${{ steps.extract_branch.outputs.tag }}
  69. make-branch-env:
  70. needs: build
  71. runs-on: ubuntu-latest
  72. steps:
  73. - name: clone
  74. run: |
  75. git clone https://infra-tech:${{ secrets.INFRA_USER_ACCESS_TOKEN }}@github.com/provectus/kafka-ui-infra.git --branch envs
  76. - name: create deployment
  77. run: |
  78. cd kafka-ui-infra/aws-infrastructure4eks/argocd/scripts
  79. echo "Branch:${{ needs.build.outputs.tag }}"
  80. ./kafka-ui-deployment-from-branch.sh ${{ needs.build.outputs.tag }} ${{ github.event.label.name }} ${{ secrets.FEATURE_TESTING_UI_PASSWORD }}
  81. git config --global user.email "infra-tech@provectus.com"
  82. git config --global user.name "infra-tech"
  83. git add ../kafka-ui-from-branch/
  84. git commit -m "added env:${{ needs.build.outputs.deploy }}" && git push || true
  85. - name: update status check for private deployment
  86. if: ${{ github.event.label.name == 'status/feature_testing' }}
  87. uses: Sibz/github-status-action@v1.1.6
  88. with:
  89. authToken: ${{secrets.GITHUB_TOKEN}}
  90. context: "Click Details button to open custom deployment page"
  91. state: "success"
  92. sha: ${{ github.event.pull_request.head.sha || github.sha }}
  93. target_url: "http://${{ needs.build.outputs.tag }}.internal.kafka-ui.provectus.io"
  94. - name: update status check for public deployment
  95. if: ${{ github.event.label.name == 'status/feature_testing_public' }}
  96. uses: Sibz/github-status-action@v1.1.6
  97. with:
  98. authToken: ${{secrets.GITHUB_TOKEN}}
  99. context: "Click Details button to open custom deployment page"
  100. state: "success"
  101. sha: ${{ github.event.pull_request.head.sha || github.sha }}
  102. target_url: "http://${{ needs.build.outputs.tag }}.internal.kafka-ui.provectus.io"