Compare commits
13 Commits
c2f8f92613
...
155412f0fa
Author | SHA1 | Date | |
---|---|---|---|
155412f0fa | |||
|
4410b862dd | ||
|
d105075746 | ||
fc01439199 | |||
|
5d8f189913 | ||
|
9fd5a9f875 | ||
|
e51b103a3f | ||
|
feb5dd7e7f | ||
|
ee6014601e | ||
|
93e15da0e2 | ||
|
a0167e5df7 | ||
7965a42ee5 | |||
c376d376dd |
24
.github/workflows/build.yml
vendored
24
.github/workflows/build.yml
vendored
@ -3,7 +3,12 @@
|
|||||||
|
|
||||||
name: Build
|
name: Build
|
||||||
|
|
||||||
on: push
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- "renovate/**"
|
||||||
|
tags-ignore:
|
||||||
|
- "**"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-gradle:
|
build-gradle:
|
||||||
@ -14,8 +19,9 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
|
|
||||||
- name: Grant execute permission for gradlew
|
- name: Grant execute permission for gradlew
|
||||||
@ -46,10 +52,10 @@ jobs:
|
|||||||
path: build/libs/
|
path: build/libs/
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Login to ghcr.io
|
- name: Login to ghcr.io
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
@ -57,20 +63,14 @@ jobs:
|
|||||||
|
|
||||||
- name: Get branch name
|
- name: Get branch name
|
||||||
id: branch-name
|
id: branch-name
|
||||||
uses: tj-actions/branch-names@v5.2
|
uses: tj-actions/branch-names@v5.3
|
||||||
|
|
||||||
- name: Set tag master
|
|
||||||
if: steps.branch-name.outputs.current_branch == 'master'
|
|
||||||
run: |
|
|
||||||
echo "tag=latest" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Set tag
|
- name: Set tag
|
||||||
if: steps.branch-name.outputs.current_branch != 'master'
|
|
||||||
run: |
|
run: |
|
||||||
echo "tag=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV
|
echo "tag=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build and push Docker
|
- name: Build and push Docker
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
context: .
|
context: .
|
||||||
|
78
.github/workflows/release.yml
vendored
Normal file
78
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# This workflow will build a Java project with Gradle
|
||||||
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||||
|
|
||||||
|
name: Build Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "**"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-gradle:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: 17
|
||||||
|
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
|
||||||
|
- name: Build with Gradle
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
- name: Upload Jar File
|
||||||
|
uses: actions/upload-artifact@v2-preview
|
||||||
|
with:
|
||||||
|
name: claptrap_jar
|
||||||
|
path: build/libs/
|
||||||
|
|
||||||
|
build-docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build-gradle
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Download artifact
|
||||||
|
uses: actions/download-artifact@v3.0.0
|
||||||
|
with:
|
||||||
|
# Artifact name
|
||||||
|
name: claptrap_jar
|
||||||
|
# Destination path
|
||||||
|
path: build/libs/
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to ghcr.io
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.CR_PAT }}
|
||||||
|
|
||||||
|
- name: Get branch name
|
||||||
|
id: branch-name
|
||||||
|
uses: tj-actions/branch-names@v5.3
|
||||||
|
|
||||||
|
- name: Set tag
|
||||||
|
run: |
|
||||||
|
echo "tag=${{ steps.branch-name.outputs.tag }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build and push Docker
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
context: .
|
||||||
|
tags: |
|
||||||
|
ghcr.io/sebclem/claptrapbot:${{ env.tag }}
|
||||||
|
ghcr.io/sebclem/claptrapbot:latest
|
||||||
|
file: ./Dockerfile
|
@ -1,10 +1,10 @@
|
|||||||
FROM openjdk:17.0.2
|
FROM openjdk:18.0.1
|
||||||
WORKDIR /bot_src
|
WORKDIR /bot_src
|
||||||
ARG BUILD_NBR
|
ARG BUILD_NBR
|
||||||
ARG BRANCH_NAME
|
ARG BRANCH_NAME
|
||||||
ARG BRANCH_NAME
|
ARG BRANCH_NAME
|
||||||
ARG GITHUB_RUN_NUMBER
|
ARG GITHUB_RUN_NUMBER
|
||||||
ADD build/libs/ClaptrapBot-*.jar /bot_src/bot.jar
|
ADD build/libs/ClaptrapBot.jar /bot_src/claptrapbot.jar
|
||||||
RUN java -version
|
RUN java -version
|
||||||
CMD java -jar bot.jar
|
CMD java -jar claptrapbot.jar
|
||||||
LABEL org.opencontainers.image.source=https://github.com/Sebclem/ClaptrapBot/
|
LABEL org.opencontainers.image.source=https://github.com/Sebclem/ClaptrapBot/
|
46
build.gradle
46
build.gradle
@ -4,19 +4,14 @@ plugins {
|
|||||||
id 'java'
|
id 'java'
|
||||||
id 'groovy'
|
id 'groovy'
|
||||||
id 'org.liquibase.gradle' version '2.1.1'
|
id 'org.liquibase.gradle' version '2.1.1'
|
||||||
id "nebula.lint" version "16.26.0"
|
id "nebula.lint" version "17.7.0"
|
||||||
|
id "com.gorylenko.gradle-git-properties" version "2.4.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def versionObj = new Version(major: 0, minor: 2, revision: 0)
|
|
||||||
|
|
||||||
group = "net.broken"
|
group = "net.broken"
|
||||||
archivesBaseName = "ClaptrapBot"
|
archivesBaseName = "ClaptrapBot"
|
||||||
version = "$versionObj"
|
|
||||||
|
|
||||||
sourceCompatibility = '17'
|
sourceCompatibility = '17'
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
@ -27,7 +22,6 @@ jar {
|
|||||||
enabled(false)
|
enabled(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
configurations.implementation {
|
configurations.implementation {
|
||||||
exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
|
exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
|
||||||
}
|
}
|
||||||
@ -38,6 +32,8 @@ dependencies {
|
|||||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-log4j2")
|
implementation("org.springframework.boot:spring-boot-starter-log4j2")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
|
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
|
||||||
|
implementation('org.springframework.boot:spring-boot-starter-actuator')
|
||||||
|
implementation('io.micrometer:micrometer-registry-prometheus:1.9.1')
|
||||||
|
|
||||||
implementation('org.springdoc:springdoc-openapi-ui:1.6.9')
|
implementation('org.springdoc:springdoc-openapi-ui:1.6.9')
|
||||||
implementation('org.springdoc:springdoc-openapi-security:1.6.9')
|
implementation('org.springdoc:springdoc-openapi-security:1.6.9')
|
||||||
@ -48,28 +44,28 @@ dependencies {
|
|||||||
implementation('io.jsonwebtoken:jjwt-impl:0.11.5')
|
implementation('io.jsonwebtoken:jjwt-impl:0.11.5')
|
||||||
implementation('io.jsonwebtoken:jjwt-jackson:0.11.5')
|
implementation('io.jsonwebtoken:jjwt-jackson:0.11.5')
|
||||||
|
|
||||||
implementation 'com.sedmelluq:lavaplayer:1.3.77'
|
implementation('com.sedmelluq:lavaplayer:1.3.78')
|
||||||
implementation 'net.dv8tion:JDA:4.4.0_350'
|
implementation('net.dv8tion:JDA:4.4.0_350')
|
||||||
|
|
||||||
implementation(platform("org.apache.logging.log4j:log4j-bom:2.17.1"))
|
implementation(platform("org.apache.logging.log4j:log4j-bom:2.17.2"))
|
||||||
implementation group: 'org.hibernate', name: 'hibernate-validator', version: '7.0.4.Final'
|
implementation group: 'org.hibernate', name: 'hibernate-validator', version: '7.0.4.Final'
|
||||||
|
|
||||||
// Use MySQL Connector-J
|
// Use MySQL Connector-J
|
||||||
implementation 'mysql:mysql-connector-java:8.0.29'
|
implementation('mysql:mysql-connector-java:8.0.29')
|
||||||
implementation 'org.reflections:reflections:0.10.2'
|
implementation('org.reflections:reflections:0.10.2')
|
||||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
implementation('org.apache.commons:commons-lang3:3.12.0')
|
||||||
|
|
||||||
|
|
||||||
liquibaseRuntime 'org.liquibase:liquibase-core:4.12.0'
|
liquibaseRuntime('org.liquibase:liquibase-core:4.12.0')
|
||||||
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:3.0.2'
|
liquibaseRuntime('org.liquibase:liquibase-groovy-dsl:3.0.2')
|
||||||
liquibaseRuntime 'mysql:mysql-connector-java:8.0.29'
|
liquibaseRuntime('mysql:mysql-connector-java:8.0.29')
|
||||||
liquibaseRuntime group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
|
liquibaseRuntime group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
|
||||||
liquibaseRuntime group: 'org.liquibase.ext', name: 'liquibase-hibernate5', version: '4.12.0'
|
liquibaseRuntime group: 'org.liquibase.ext', name: 'liquibase-hibernate5', version: '4.12.0'
|
||||||
liquibaseRuntime 'org.springframework.boot:spring-boot-starter-data-jpa'
|
liquibaseRuntime 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
liquibaseRuntime 'org.springframework.data:spring-data-jpa'
|
liquibaseRuntime 'org.springframework.data:spring-data-jpa'
|
||||||
liquibaseRuntime 'org.springframework:spring-beans'
|
liquibaseRuntime 'org.springframework:spring-beans'
|
||||||
liquibaseRuntime 'net.dv8tion:JDA:4.4.0_350'
|
liquibaseRuntime 'net.dv8tion:JDA:4.4.0_350'
|
||||||
liquibaseRuntime 'com.sedmelluq:lavaplayer:1.3.77'
|
liquibaseRuntime 'com.sedmelluq:lavaplayer:1.3.78'
|
||||||
liquibaseRuntime sourceSets.main.output
|
liquibaseRuntime sourceSets.main.output
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -89,17 +85,3 @@ liquibase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Version {
|
|
||||||
String major, minor, revision
|
|
||||||
|
|
||||||
static String getBuild() {
|
|
||||||
System.getenv("GITHUB_RUN_NUMBER") ?: System.getProperty("BUILD_NUMBER") ?:
|
|
||||||
System.getenv("GIT_COMMIT")?.substring(0, 7) ?: System.getProperty("GIT_COMMIT")?.substring(0, 7) ?: "DEV"
|
|
||||||
}
|
|
||||||
|
|
||||||
String toString() {
|
|
||||||
"${major}.${minor}.${revision}_$build"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
"extends": [
|
"extends": [
|
||||||
"config:base"
|
"config:base"
|
||||||
],
|
],
|
||||||
"commitMessageSuffix": "[skip ci]"
|
"commitMessagePrefix": ":arrow_up:"
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ public class GuildController {
|
|||||||
|
|
||||||
@GetMapping("inviteLink")
|
@GetMapping("inviteLink")
|
||||||
public InviteLink getInviteLink() {
|
public InviteLink getInviteLink() {
|
||||||
String link = MainBot.jda.setRequiredScopes("applications.commands").getInviteUrl(Permission.getPermissions(1644971949399L));
|
|
||||||
return new InviteLink(link);
|
return new InviteLink(guildService.getInviteLink());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{guildId}/voiceChannels")
|
@GetMapping("/{guildId}/voiceChannels")
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package net.Broken.Api.Controllers;
|
|
||||||
|
|
||||||
import net.Broken.Api.Security.Data.JwtPrincipal;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/v2/hello")
|
|
||||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
|
||||||
public class HelloController {
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("world")
|
|
||||||
public String helloWorld(Authentication authentication){
|
|
||||||
JwtPrincipal principal = (JwtPrincipal) authentication.getPrincipal();
|
|
||||||
return "Hello " + principal.user().getUsername();
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,33 +2,34 @@ package net.Broken.Api.OpenApi;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.models.Components;
|
import io.swagger.v3.oas.models.Components;
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||||
import io.swagger.v3.oas.models.servers.Server;
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
|
import net.Broken.VersionLoader;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class OpenApiConfig {
|
public class OpenApiConfig {
|
||||||
|
private final VersionLoader versionLoader;
|
||||||
|
|
||||||
|
public OpenApiConfig(VersionLoader version) {
|
||||||
|
this.versionLoader = version;
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public OpenAPI customOpenAPI() {
|
public OpenAPI customOpenAPI() {
|
||||||
final String securitySchemeName = "JWT";
|
final String securitySchemeName = "JWT";
|
||||||
|
return new OpenAPI().addSecurityItem(
|
||||||
// final String apiTitle = String.format("%s API", StringUtils.capitalize(moduleName));
|
new SecurityRequirement().addList(securitySchemeName)).components(
|
||||||
return new OpenAPI()
|
new Components().addSecuritySchemes(
|
||||||
.addSecurityItem(new SecurityRequirement().addList(securitySchemeName))
|
securitySchemeName,
|
||||||
.components(
|
new SecurityScheme().name(securitySchemeName)
|
||||||
new Components()
|
.type(SecurityScheme.Type.HTTP)
|
||||||
.addSecuritySchemes(securitySchemeName,
|
.scheme("bearer")
|
||||||
new SecurityScheme()
|
.bearerFormat("JWT"))
|
||||||
.name(securitySchemeName)
|
).addServersItem(new Server().url("/").description("Default"))
|
||||||
.type(SecurityScheme.Type.HTTP)
|
.info(new Info().title("ClaptrapBot API").version(versionLoader.getVersion()));
|
||||||
.scheme("bearer")
|
|
||||||
.bearerFormat("JWT")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.addServersItem(new Server().url("/").description("Default"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,6 +29,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
.antMatchers("/swagger-ui/**").permitAll()
|
.antMatchers("/swagger-ui/**").permitAll()
|
||||||
.antMatchers("/swagger-ui.html").permitAll()
|
.antMatchers("/swagger-ui.html").permitAll()
|
||||||
.antMatchers("/v3/api-docs/**").permitAll()
|
.antMatchers("/v3/api-docs/**").permitAll()
|
||||||
|
.antMatchers("/actuator/**").permitAll()
|
||||||
.anyRequest().authenticated();
|
.anyRequest().authenticated();
|
||||||
|
|
||||||
http.addFilterBefore(jwtFilter(), UsernamePasswordAuthenticationFilter.class);
|
http.addFilterBefore(jwtFilter(), UsernamePasswordAuthenticationFilter.class);
|
||||||
|
@ -66,4 +66,9 @@ public class GuildService {
|
|||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getInviteLink(){
|
||||||
|
return MainBot.jda.setRequiredScopes("applications.commands").getInviteUrl(Permission.getPermissions(1644971949399L));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import javax.security.auth.login.LoginException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class Init {
|
public class Init {
|
||||||
static private final Logger logger = LogManager.getLogger();
|
static private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -32,11 +35,14 @@ public class MainBot {
|
|||||||
|
|
||||||
ConfigurableApplicationContext ctx = SpringApplication.run(MainBot.class, args);
|
ConfigurableApplicationContext ctx = SpringApplication.run(MainBot.class, args);
|
||||||
BotConfigLoader config = ctx.getBean(BotConfigLoader.class);
|
BotConfigLoader config = ctx.getBean(BotConfigLoader.class);
|
||||||
|
VersionLoader versionLoader = ctx.getBean(VersionLoader.class);
|
||||||
|
|
||||||
logger.info("=======================================");
|
logger.info("=======================================");
|
||||||
logger.info("--------------Starting Bot-------------");
|
logger.info("--------------Starting Bot-------------");
|
||||||
logger.info("=======================================");
|
logger.info("=======================================");
|
||||||
|
|
||||||
|
logger.info("Version: " + versionLoader.getVersion());
|
||||||
|
|
||||||
jda = Init.initJda(config);
|
jda = Init.initJda(config);
|
||||||
if (jda == null) {
|
if (jda == null) {
|
||||||
System.exit(SpringApplication.exit(ctx, () -> {
|
System.exit(SpringApplication.exit(ctx, () -> {
|
||||||
@ -47,4 +53,14 @@ public class MainBot {
|
|||||||
Init.polish(jda, config);
|
Init.polish(jda, config);
|
||||||
ready = true;
|
ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
|
||||||
|
PropertySourcesPlaceholderConfigurer propsConfig
|
||||||
|
= new PropertySourcesPlaceholderConfigurer();
|
||||||
|
propsConfig.setLocation(new ClassPathResource("git.properties"));
|
||||||
|
propsConfig.setIgnoreResourceNotFound(true);
|
||||||
|
propsConfig.setIgnoreUnresolvablePlaceholders(true);
|
||||||
|
return propsConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
24
src/main/java/net/Broken/VersionLoader.java
Normal file
24
src/main/java/net/Broken/VersionLoader.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package net.Broken;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class VersionLoader {
|
||||||
|
@Value("${git.branch}")
|
||||||
|
private String branch;
|
||||||
|
@Value("${git.tags}")
|
||||||
|
private String tags;
|
||||||
|
@Value("${git.commit.id.abbrev}")
|
||||||
|
private String commitId;
|
||||||
|
|
||||||
|
public String getVersion(){
|
||||||
|
String version;
|
||||||
|
if(tags.isEmpty()){
|
||||||
|
version = "DEV-" + branch + "-" + commitId;
|
||||||
|
}else{
|
||||||
|
version = tags;
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
@ -27,4 +27,19 @@ discord:
|
|||||||
randomApiKey: ${RANDOM_API_KEY}
|
randomApiKey: ${RANDOM_API_KEY}
|
||||||
|
|
||||||
springdoc:
|
springdoc:
|
||||||
paths-to-match: /api/v2/**
|
paths-to-match: /api/v2/**
|
||||||
|
show-actuator: true
|
||||||
|
|
||||||
|
management:
|
||||||
|
info:
|
||||||
|
git:
|
||||||
|
mode: full
|
||||||
|
enabled: true
|
||||||
|
endpoints:
|
||||||
|
enabled-by-default: true
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: health, info, prometheus
|
||||||
|
endpoint:
|
||||||
|
prometheus:
|
||||||
|
enabled: true
|
Loading…
Reference in New Issue
Block a user