buildAndRelease.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. name: Release
  2. on:
  3. push:
  4. branches: [ main ]
  5. workflow_dispatch:
  6. inputs:
  7. branch:
  8. description: 'Branch to build'
  9. required: true
  10. default: 'main'
  11. type: string
  12. jobs:
  13. build-and-test:
  14. name: Build and Test
  15. runs-on: ubuntu-latest
  16. steps:
  17. - uses: actions/checkout@v3
  18. with:
  19. ref: ${{ github.event.inputs.branch || github.ref }}
  20. - name: Set up JDK
  21. uses: actions/setup-java@v3
  22. with:
  23. java-version: '25'
  24. distribution: 'temurin'
  25. - name: Build with Gradle
  26. run: chmod +x ./gradlew && ./gradlew clean build test
  27. dockerize:
  28. name: Dockerize Application
  29. needs: build-and-test
  30. runs-on: ubuntu-latest
  31. steps:
  32. - uses: actions/checkout@v3
  33. with:
  34. ref: ${{ github.event.inputs.branch || github.ref }}
  35. - name: Set up JDK
  36. uses: actions/setup-java@v3
  37. with:
  38. java-version: '25'
  39. distribution: 'temurin'
  40. - name: Build
  41. run: ./gradlew build
  42. - name: Set up Docker Buildx
  43. uses: docker/setup-buildx-action@v2
  44. - name: Login to Docker Hub
  45. uses: docker/login-action@v2
  46. with:
  47. username: ${{ secrets.DOCKERHUB_USERNAME }}
  48. password: ${{ secrets.DOCKERHUB_TOKEN }}
  49. - name: Build and Push Image
  50. run: |
  51. docker buildx create --use
  52. docker buildx build --platform linux/amd64,linux/arm64 -t dbohry/auth-service:latest --push .