Skip to content

Commit

Permalink
chore: build CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Touyu-Pan committed Oct 3, 2024
1 parent d05438d commit 3c4f46c
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main


concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
project-build:
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21

- name: Build with Gradle
run: ./gradlew build

- name: Build Docker image
run: docker build --build-arg JAR_FILE=build/libs/\*.jar -t springio/gs-spring-boot-docker .
34 changes: 34 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main


concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
project-build:
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21

- name: Build with Gradle
run: ./gradlew build

- name: Build Docker image
run: docker build --build-arg JAR_FILE=build/libs/\*.jar -t springio/gs-spring-boot-docker .
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:21
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
16 changes: 12 additions & 4 deletions src/main/java/tw/commonground/backend/BackendApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class BackendApplication {

public static void main(String[] args) {
SpringApplication.run(BackendApplication.class, args);
}
@RequestMapping("/")
public String home() {
return "Hello Docker World";
}

}
public static void main(String[] args) {
SpringApplication.run(BackendApplication.class, args);
}

}

0 comments on commit 3c4f46c

Please sign in to comment.