-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e34b555
commit 67c50d4
Showing
8 changed files
with
118 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
lint: | ||
if: github.event.pull_request.merged == false | ||
uses: heliannuuthus/integration-deploy/.github/workflows/call-gradle-lint.yml@master | ||
|
||
build: | ||
needs: lint | ||
uses: heliannuuthus/integration-deploy/.github/workflows/call-gradle-build.yml@master | ||
|
||
publish: | ||
if: github.event.pull_request.merged == true | ||
needs: build | ||
permissions: | ||
contents: read | ||
packages: write | ||
uses: heliannuuthus/integration-deploy/.github/workflows/call-gradle-publish.yml@master | ||
with: | ||
user: ${{ github.actor }} | ||
secrets: | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
groups=ghrc.io | ||
version=0.1.0 |
61 changes: 35 additions & 26 deletions
61
...annuus-apollo-client/src/main/java/io/ghcr/heliannuuthus/ApolloMetaServerInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,48 @@ | ||
package io.ghcr.heliannuuthus; | ||
|
||
import com.ctrip.framework.apollo.core.ApolloClientSystemConsts; | ||
import java.text.MessageFormat; | ||
import java.util.Arrays; | ||
import java.util.Optional; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.ApplicationContextInitializer; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.core.env.ConfigurableEnvironment; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.Arrays; | ||
import java.util.Optional; | ||
|
||
@Slf4j | ||
public class ApolloMetaServerInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext>, Ordered { | ||
public static final int ORDER = -1; | ||
private static final String SCHEMA = "config"; | ||
private static final String SPRING_APPLICATION_NAME_KEY = "spring.application.name"; | ||
private static final String SPRING_PROFILES_ACTIVE_KEY = "spring.profiles.active"; | ||
private static final String DEFAULT_META_SERVER = "http://{0}.heliannuuthus.com"; | ||
private static final String DEFAULT_ENV = "dev"; | ||
private static final String PROD_ENV = "prod"; | ||
public class ApolloMetaServerInitializer | ||
implements ApplicationContextInitializer<ConfigurableApplicationContext>, Ordered { | ||
public static final int ORDER = -1; | ||
private static final String SCHEMA = "config"; | ||
private static final String SPRING_APPLICATION_NAME_KEY = "spring.application.name"; | ||
private static final String SPRING_PROFILES_ACTIVE_KEY = "spring.profiles.active"; | ||
private static final String DEFAULT_META_SERVER = "http://{0}.heliannuuthus.com"; | ||
private static final String DEFAULT_ENV = "dev"; | ||
private static final String PROD_ENV = "prod"; | ||
|
||
private static final String MIDDLE_LINE = "-"; | ||
private static final String MIDDLE_LINE = "-"; | ||
|
||
@Override | ||
public int getOrder() { | ||
return ORDER; | ||
} | ||
@Override | ||
public int getOrder() { | ||
return ORDER; | ||
} | ||
|
||
@Override | ||
public void initialize(ConfigurableApplicationContext applicationContext) { | ||
ConfigurableEnvironment environment = applicationContext.getEnvironment(); | ||
Optional.ofNullable(environment.getProperty(SPRING_APPLICATION_NAME_KEY)).ifPresent(applicationName -> System.setProperty(ApolloClientSystemConsts.APP_ID, applicationName)); | ||
String env = Optional.of(environment.getActiveProfiles()).flatMap(profiles -> Arrays.stream(profiles).findFirst()).orElse(DEFAULT_ENV); | ||
System.setProperty("env", env); | ||
System.setProperty(ApolloClientSystemConsts.APOLLO_META, MessageFormat.format(DEFAULT_META_SERVER, PROD_ENV.equals(env) ? SCHEMA : SCHEMA + MIDDLE_LINE + env)); | ||
} | ||
} | ||
@Override | ||
public void initialize(ConfigurableApplicationContext applicationContext) { | ||
ConfigurableEnvironment environment = applicationContext.getEnvironment(); | ||
Optional.ofNullable(environment.getProperty(SPRING_APPLICATION_NAME_KEY)) | ||
.ifPresent( | ||
applicationName -> | ||
System.setProperty(ApolloClientSystemConsts.APP_ID, applicationName)); | ||
String env = | ||
Optional.of(environment.getActiveProfiles()) | ||
.flatMap(profiles -> Arrays.stream(profiles).findFirst()) | ||
.orElse(DEFAULT_ENV); | ||
System.setProperty("env", env); | ||
System.setProperty( | ||
ApolloClientSystemConsts.APOLLO_META, | ||
MessageFormat.format( | ||
DEFAULT_META_SERVER, PROD_ENV.equals(env) ? SCHEMA : SCHEMA + MIDDLE_LINE + env)); | ||
} | ||
} |
16 changes: 0 additions & 16 deletions
16
helianthus-annuus-apollo-client/src/main/java/io/ghcr/heliannuuthus/DevtoolsApplication.java
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
helianthus-annuus-apollo-client/src/main/resources/application.yaml
This file was deleted.
Oops, something went wrong.
97 changes: 44 additions & 53 deletions
97
helianthus-annuus-openapi/src/main/java/io/ghcr/heliannuuthus/OpenapiConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,44 @@ | ||
package io.ghcr.heliannuuthus; | ||
|
||
|
||
import io.swagger.v3.oas.models.ExternalDocumentation; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import io.swagger.v3.oas.models.info.License; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
|
||
@Slf4j | ||
@Configuration | ||
public class OpenapiConfiguration { | ||
|
||
@Value("${spring.application.name}") | ||
private String application; | ||
|
||
@Value("${server.port}") | ||
private String port; | ||
|
||
@Value("${server.address:localhost}") | ||
private String serverAddress; | ||
|
||
private License license() { | ||
return new License() | ||
.name("MIT") | ||
.url("https://opensource.org/licenses/MIT"); | ||
} | ||
|
||
private Info info() { | ||
return new Info() | ||
.title(application) | ||
.version("v1.0.0") | ||
.license(license()); | ||
} | ||
|
||
private ExternalDocumentation externalDocumentation() { | ||
return new ExternalDocumentation() | ||
.description("heliannuuthus") | ||
.url("https://heliannuuthus.github.io/"); | ||
} | ||
|
||
@Bean | ||
public OpenAPI springShopOpenAPI() { | ||
log.info("openapi: http://{}:{}/redoc.html", serverAddress, port); | ||
return new OpenAPI() | ||
.info(info()) | ||
.externalDocs(externalDocumentation()); | ||
} | ||
} | ||
package io.ghcr.heliannuuthus; | ||
|
||
import io.swagger.v3.oas.models.ExternalDocumentation; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import io.swagger.v3.oas.models.info.License; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Slf4j | ||
@Configuration | ||
public class OpenapiConfiguration { | ||
|
||
@Value("${spring.application.name}") | ||
private String application; | ||
|
||
@Value("${server.port}") | ||
private String port; | ||
|
||
@Value("${server.address:localhost}") | ||
private String serverAddress; | ||
|
||
private License license() { | ||
return new License().name("MIT").url("https://opensource.org/licenses/MIT"); | ||
} | ||
|
||
private Info info() { | ||
return new Info().title(application).version("v1.0.0").license(license()); | ||
} | ||
|
||
private ExternalDocumentation externalDocumentation() { | ||
return new ExternalDocumentation() | ||
.description("heliannuuthus") | ||
.url("https://heliannuuthus.github.io/"); | ||
} | ||
|
||
@Bean | ||
public OpenAPI springShopOpenAPI() { | ||
log.info("openapi: http://{}:{}/redoc.html", serverAddress, port); | ||
return new OpenAPI().info(info()).externalDocs(externalDocumentation()); | ||
} | ||
} |