feat: add makefile commands (#26) #48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| branches: [main, develop] | |
| push: | |
| branches: [main] | |
| jobs: | |
| build-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml | |
| - name: Run tests with dev profile | |
| run: mvn test -Dspring.profiles.active=dev | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: target/surefire-reports/ | |
| docker: | |
| needs: build-test | |
| if: success() && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract version from pom.xml | |
| id: get_version | |
| run: | | |
| VERSION=$(grep "<version>" pom.xml | head -1 | sed 's/.*<version>\(.*\)<\/version>.*/\1/') | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/jwt-auth-server:latest | |
| ${{ secrets.DOCKERHUB_USERNAME }}/jwt-auth-server:${{ env.VERSION }} | |
| cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/jwt-auth-server:buildcache | |
| cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/jwt-auth-server:buildcache,mode=max |