1- # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3-
4- # This workflow uses actions that are not certified by GitHub.
5- # They are provided by a third-party and are governed by
6- # separate terms of service, privacy policy, and support
7- # documentation.
8-
9- name : Java CI with Maven
1+ name : Java CI,CD with Maven
102
113on :
124 push :
@@ -50,15 +42,28 @@ jobs:
5042 CACHE_URL : localhost
5143 CACHE_PORT : 6379
5244 steps :
53- - name : Checkout code
54- uses : actions/checkout@v4
55-
56- - name : Set up JDK 17
57- uses : actions/setup-java@v4
58- with :
59- java-version : ' 17'
60- distribution : ' temurin'
61- cache : maven
62-
63- - name : Run tests
64- run : mvn test
45+ - name : Checkout code
46+ uses : actions/checkout@v4
47+
48+ - name : Set up JDK 17
49+ uses : actions/setup-java@v4
50+ with :
51+ java-version : ' 17'
52+ distribution : ' corretto'
53+ cache : maven
54+
55+ - name : Run tests and build with Maven
56+ run : mvn clean package
57+
58+ - name : Log in to GitHub Container Registry
59+ uses : docker/login-action@v3
60+ with :
61+ registry : ghcr.io
62+ username : ${{ github.actor }}
63+ password : ${{ secrets.GITHUB_TOKEN }}
64+
65+ - name : Build Docker image
66+ run : docker build -f .github/Dockerfile -t ghcr.io/${{ github.repository_owner }}/spring-backend:latest .
67+
68+ - name : Push Docker image
69+ run : docker push ghcr.io/${{ github.repository_owner }}/spring-backend:latest
0 commit comments