Skip to content

Commit 655e6b9

Browse files
Update maven.yml
Try build docker and push to docker hub
1 parent d2a4f53 commit 655e6b9

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

.github/workflows/maven.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
# separate terms of service, privacy policy, and support
77
# documentation.
88

9+
# Action name
910
name: Java CI with Maven
1011

12+
# When will the action run
1113
on:
1214
push:
1315
branches: [ "testGitHub-Action" ]
1416
pull_request:
1517
branches: [ "testGitHub-Action" ]
1618

1719
jobs:
20+
# build the project
1821
build:
1922

2023
runs-on: ubuntu-latest
@@ -30,10 +33,34 @@ jobs:
3033
java-version: '17'
3134
distribution: 'temurin'
3235
cache: maven
36+
3337
- name: Build with Maven
3438
run: mvn clean package --file pom.xml
35-
- name: Upload artifact
36-
uses: actions/upload-artifact@v4
37-
with:
38-
name: bu-secondhand-1.0.0
39-
path: ./code/backend/target/bu-secondhand-1.0.0.jar
39+
40+
# - name: Upload artifact
41+
# uses: actions/upload-artifact@v4
42+
# with:
43+
# name: bu-secondhand-1.0.0
44+
# path: ./code/backend/target/bu-secondhand-1.0.0.jar
45+
46+
# build a docker image and push it to Docker Hub
47+
deploy:
48+
runs-on: ubuntu-latest
49+
defaults:
50+
run:
51+
working-directory: ./code/backend
52+
steps:
53+
- name: Login to Docker Hub
54+
uses: docker/login-action@v3
55+
with:
56+
username: ${{ vars.DOCKERHUB_USERNAME }}
57+
password: ${{ secrets.DOCKERHUB_TOKEN }}
58+
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@v3
61+
62+
- name: Build and push
63+
uses: docker/build-push-action@v6
64+
with:
65+
push: true
66+
tags: ${{ vars.DOCKERHUB_USERNAME }}/campus_exchange:latest

0 commit comments

Comments
 (0)