buildAndRelease.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. name: Release
  2. on:
  3. push:
  4. branches: [ main ]
  5. jobs:
  6. build-and-test:
  7. name: Build and Test
  8. runs-on: ubuntu-latest
  9. steps:
  10. - uses: actions/checkout@v3
  11. - name: Set up JDK
  12. uses: actions/setup-java@v3
  13. with:
  14. java-version: '21'
  15. distribution: 'temurin'
  16. - name: Build with Gradle
  17. run: chmod +x ./gradlew && ./gradlew clean build test
  18. dockerize:
  19. name: Dockerize Application
  20. needs: build-and-test
  21. runs-on: ubuntu-latest
  22. steps:
  23. - uses: actions/checkout@v3
  24. - name: Set up Docker Buildx
  25. uses: docker/setup-buildx-action@v1
  26. - name: Cache Docker layers
  27. uses: actions/cache@v2
  28. with:
  29. path: /tmp/.buildx-cache
  30. key: ${{ runner.os }}-buildx-${{ github.sha }}
  31. restore-keys: ${{ runner.os }}-buildx-
  32. - name: Set up JDK
  33. uses: actions/setup-java@v3
  34. with:
  35. java-version: '21'
  36. distribution: 'temurin'
  37. - name: Build the Docker image
  38. run: ./gradlew build && docker build -t dbohry/auth-service .
  39. - name: Login to Docker Hub
  40. uses: docker/login-action@v2
  41. with:
  42. username: ${{ secrets.DOCKERHUB_USERNAME }}
  43. password: ${{ secrets.DOCKERHUB_TOKEN }}
  44. - name: Push image
  45. run: docker push dbohry/auth-service