buildAndRelease.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: Release
  2. env:
  3. MONGO: ${{ secrets.MONGO }}
  4. on:
  5. push:
  6. branches: [ main ]
  7. jobs:
  8. build-and-test:
  9. name: Build and Test
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/checkout@v3
  13. - name: Set up JDK
  14. uses: actions/setup-java@v3
  15. with:
  16. java-version: '21'
  17. distribution: 'temurin'
  18. - name: Build with Gradle
  19. run: chmod +x ./gradlew && ./gradlew clean build test
  20. dockerize:
  21. name: Dockerize Application
  22. needs: build-and-test
  23. runs-on: ubuntu-latest
  24. steps:
  25. - uses: actions/checkout@v3
  26. - name: Set up Docker Buildx
  27. uses: docker/setup-buildx-action@v1
  28. - name: Set up JDK
  29. uses: actions/setup-java@v3
  30. with:
  31. java-version: '21'
  32. distribution: 'temurin'
  33. - name: Build the Docker image
  34. run: ./gradlew build && docker build -t lhamacorp/stocks-be .
  35. - name: Login to Docker Hub
  36. uses: docker/login-action@v2
  37. with:
  38. username: ${{ secrets.DOCKERHUB_USERNAME }}
  39. password: ${{ secrets.DOCKERHUB_TOKEN }}
  40. - name: Push image
  41. run: docker push lhamacorp/stocks-be
  42. dockerize-arm:
  43. name: Dockerize ARM Application
  44. needs: build-and-test
  45. runs-on: ubuntu-latest
  46. steps:
  47. - uses: actions/checkout@v3
  48. - name: Set up JDK
  49. uses: actions/setup-java@v3
  50. with:
  51. java-version: '21'
  52. distribution: 'temurin'
  53. - name: Build
  54. run: ./gradlew build
  55. - name: Set up Docker Buildx
  56. uses: docker/setup-buildx-action@v2
  57. - name: Login to Docker Hub
  58. uses: docker/login-action@v2
  59. with:
  60. username: ${{ secrets.DOCKERHUB_USERNAME }}
  61. password: ${{ secrets.DOCKERHUB_TOKEN }}
  62. - name: Build and Push ARM Image
  63. run: |
  64. docker buildx create --use
  65. docker buildx build --platform linux/arm64 -t lhamacorp/stocks-be:latest --push .