Skip to content

Commit

Permalink
Merge pull request #6 from bekk/gh-actions-build
Browse files Browse the repository at this point in the history
Build jar containing frontend and backend
  • Loading branch information
vegarrsm authored Aug 30, 2023
2 parents db848c9 + f22aa02 commit b7a4a1d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build frontend
name: Build

on:
pull_request:
Expand All @@ -8,11 +8,8 @@ on:

jobs:
build:
name: Build frontend
name: Build Jar with static frontend
runs-on: ubuntu-latest
defaults:
run:
working-directory: db-scheduler-ui-frontend

steps:
- name: Checkout repo
Expand All @@ -23,12 +20,33 @@ jobs:

- name: Install dependencies
run: npm install
working-directory: db-scheduler-ui-frontend

- name: Build project
run: npm run build
working-directory: db-scheduler-ui-frontend

- name: Create static folder in backend
run: mkdir db-scheduler-ui-backend/src/main/resources/static

- name: Copy static frontend to java package
run: cp -r db-scheduler-ui-frontend/dist/. db-scheduler-ui-backend/src/main/resources/static/

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Build java module with Maven
run: mvn --batch-mode --update-snapshots package
working-directory: db-scheduler-ui-backend

- name: look for jar file
run: ls -R db-scheduler-ui-backend

- name: Upload production-ready build files
uses: actions/upload-artifact@v3
with:
name: production-files
path: db-scheduler-ui-frontend/dist
path: db-scheduler-ui-backend/target/*.jar
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void runNow(@RequestParam String id, @RequestParam String name) {
public void deleteTaskNow(@RequestParam String id, @RequestParam String name) {
taskService.deleteTask(id, name);
}

@GetMapping("api/run/all")
public void runAllTasks(){
taskService.runAllTasks();
Expand Down
2 changes: 1 addition & 1 deletion db-scheduler-ui-frontend/src/services/deleteTask.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const API_BASE_URL: string = import.meta.env.VITE_API_BASE_URL as string;
const API_BASE_URL: string = import.meta.env.VITE_API_BASE_URL as string ?? window.location.origin + '/api';

const deleteTask = async (id: string, name: string) => {
const response = await fetch(`${API_BASE_URL}/delete?id=${id}&name=${name}`, {
Expand Down
13 changes: 0 additions & 13 deletions db-scheduler-ui-frontend/src/services/getTaskById.ts

This file was deleted.

6 changes: 3 additions & 3 deletions db-scheduler-ui-frontend/src/services/getTasks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TasksResponse } from "src/models/TasksResponse";

const API_BASE_URL: string = import.meta.env.VITE_API_BASE_URL as string;
const API_BASE_URL: string = import.meta.env.VITE_API_BASE_URL as string ?? window.location.origin + '/api';

export enum FilterBy {
All = 'All',
Expand All @@ -22,7 +22,7 @@ export enum SortBy {
export const TASK_QUERY_KEY = `tasks`;

export const getTasks = async (
filter = FilterBy.All,
filter = FilterBy.All,
{ pageNumber = 1, limit = 10 }: PaginationParams,
sorting = SortBy.Default,
isAsc = true
Expand All @@ -34,7 +34,7 @@ export const getTasks = async (
queryParams.append('size', limit.toString());
queryParams.append('sorting', sorting.toUpperCase());
queryParams.append('asc', isAsc.toString());

const response = await fetch(`${API_BASE_URL}/tasks?${queryParams}`, {
method: 'GET',
headers: {
Expand Down
2 changes: 1 addition & 1 deletion db-scheduler-ui-frontend/src/services/runTask.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const API_BASE_URL: string = import.meta.env.VITE_API_BASE_URL as string;
const API_BASE_URL: string = import.meta.env.VITE_API_BASE_URL as string ?? window.location.origin + '/api';

const runTask = async (id: string, name: string) => {
const response = await fetch(`${API_BASE_URL}/rerun?id=${id}&name=${name}`, {
Expand Down

0 comments on commit b7a4a1d

Please sign in to comment.