buildAndRelease.yml 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. - name: Set up Docker Buildx
  26. uses: docker/setup-buildx-action@v2
  27. - name: Log in to Docker Hub
  28. uses: docker/login-action@v2
  29. with:
  30. username: ${{ secrets.DOCKER_USERNAME }}
  31. password: ${{ secrets.DOCKER_TOKEN }}
  32. - name: Build and push multi-platform Docker images
  33. run: |
  34. docker buildx create --use
  35. docker buildx build --platform linux/amd64,linux/arm64 -t lhamacorp/stocks-be:latest . --push