envPath and readme fix

This commit is contained in:
LucaZanni committed 2024-07-11 09:59:25 +02:00
1 parent bb5f4d9734
commit 8ba1a8dd12
2 files changed
+15 -12

No files matched your search

+3 -2
View File
@@ -4,7 +4,7 @@ This GitHub Action generates Kubernetes YAML files from configuration and enviro
## Usage
To use this action in your GitHub workflow, add the following steps to your `.github/workflows/*.yml` file:
To use this action in your GitHub workflow, add the following steps to your `.gitea/workflows/*.yml` file:
```yaml
name: Generate K8s YAML
@@ -16,13 +16,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Generate K8s YAML
uses: ./
with:
instance: 'my-instance'
namespace: 'my-namespace'
serviceType: 'ClusterIP'
envName: '.env'
targetPort: 8080
replicas: 3
registry: 'my-registry'
+12 -10
View File
@@ -31123,21 +31123,21 @@ const exit = (msg) => {
process.exit(1);
};
const envName = core.getInput("envName") || ".env";
// Load environment variables from the .env file
const envPath = path.join(contextPath, ".env");
const envPath = path.join(contextPath, envName);
log(`envPath: ${envPath}`);
if (fs.existsSync(envPath)) {
let envConfig = {};
const envExist = fs.existsSync(envPath);
if (envExist) {
dotenv.config({ path: envPath });
log("Loaded environment variables from the .env file");
} else {
exit(`.env file not found at path ${envPath}`);
// Set default values for PORT and HOST if not defined
envConfig = dotenv.parse(fs.readFileSync(envPath));
log(`envConfig: ${JSON.stringify(envConfig)}`);
}
// Set default values for PORT and HOST if not defined
const envConfig = dotenv.parse(fs.readFileSync(envPath));
log(`envConfig: ${JSON.stringify(envConfig)}`);
// Add PORT and HOST to envConfig if not present
envConfig.PORT = parseInt(envConfig.PORT || '3000', 10);
log(`envConfig.PORT: ${envConfig.PORT}`);
@@ -31231,7 +31231,8 @@ const configMap = {
metadata: { ...baseMetadata, name: `${packageJson.name}-config` },
data: envConfig
};
log(`configMap: ${JSON.stringify(configMap)}`);
if (envExist)
log(`configMap: ${JSON.stringify(configMap)}`);
// Service
const service = {
@@ -31304,7 +31305,8 @@ const yamlOptions = {
log(`yamlOptions: ${JSON.stringify(yamlOptions)}`);
const yamlContents = [];
yamlContents.push(yaml.dump(configMap, yamlOptions));
if (envExist)
yamlContents.push(yaml.dump(configMap, yamlOptions));
yamlContents.push(yaml.dump(service, yamlOptions));
yamlContents.push(yaml.dump(deployment, yamlOptions));
yamlContents.push(yaml.dump(autoscaler, yamlOptions));