You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Publish a Docker image for a Spring Boot application, for example using com.google.cloud.tools.jib
Use this Docker image in a GitHub Actions workflow
Supply Spring Boot configuration properties using the with: clause in the GitHub Actions workflow
GitHub will pass the contents of the with: clause as environment variables to the Docker image using an INPUT_ prefix, i.e. INPUT_MY_CONFIG_PROPERTY. It would be nice if Spring Boot would support scenarios like these out of the box.
For now, I'm using a somewhat hacky work-around, passing the following custom Environment implementation to SpringApplicationBuilder:
public class MyCustomEnvironment extends StandardEnvironment {
@Override
public Map<String, Object> getSystemEnvironment() {
Map<String, Object> systemEnv = super.getSystemEnvironment();
Map<String, Object> result = systemEnv;
if ( systemEnv.containsKey("GITHUB_ACTIONS") ) {
result = new HashMap<>(systemEnv);
result.putAll(systemEnv.entrySet().stream()
.filter(e->e.getKey().startsWith("INPUT_"))
.collect(Collectors.toMap(e->e.getKey().replaceFirst("^INPUT_",""), e->e.getValue())));
}
return result;
}
}
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion. This is a duplicate of #3450. Could you please add your comment to that issue as the GitHub Actions use case is one that I don't think we've heard before.
Use case:
com.google.cloud.tools.jib
with:
clause in the GitHub Actions workflowGitHub will pass the contents of the
with:
clause as environment variables to the Docker image using anINPUT_
prefix, i.e.INPUT_MY_CONFIG_PROPERTY
. It would be nice if Spring Boot would support scenarios like these out of the box.For now, I'm using a somewhat hacky work-around, passing the following custom Environment implementation to
SpringApplicationBuilder
:The text was updated successfully, but these errors were encountered: