Skip to content

Commit 03c8e0a

Browse files
authored
Merge pull request #16 from OpsGuild/dev
refactor: Streamline GitHub Actions input parsing
2 parents 39dbeb8 + 2244eb6 commit 03c8e0a

5 files changed

Lines changed: 26 additions & 40 deletions

File tree

action.yml

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -169,36 +169,3 @@ runs:
169169
run: |
170170
cd ${{ github.action_path }}
171171
poetry run python main.py
172-
env:
173-
GIT_URL: ${{ inputs.git_url }}
174-
GIT_AUTH_METHOD: ${{ inputs.git_auth_method }}
175-
GIT_TOKEN: ${{ inputs.git_token }}
176-
GIT_USER: ${{ inputs.git_user }}
177-
GITHUB_REPOSITORY: ${{ github.repository }}
178-
GITHUB_ACTOR: ${{ github.actor }}
179-
GIT_SSH_KEY: ${{ inputs.git_ssh_key }}
180-
DEPLOYMENT_TYPE: ${{ inputs.deployment_type }}
181-
ENVIRONMENT: ${{ inputs.environment }}
182-
REMOTE_USER: ${{ inputs.remote_user }}
183-
REMOTE_HOST: ${{ inputs.remote_host }}
184-
REMOTE_DIR: ${{ inputs.remote_dir }}
185-
SSH_KEY: ${{ inputs.ssh_key }}
186-
REMOTE_PASSWORD: ${{ inputs.remote_password }}
187-
REGISTRY_TYPE: ${{ inputs.registry_type }}
188-
REGISTRY_USERNAME: ${{ inputs.registry_username }}
189-
REGISTRY_PASSWORD: ${{ inputs.registry_password }}
190-
AWS_REGION: ${{ inputs.aws_region }}
191-
AWS_ACCOUNT_ID: ${{ inputs.aws_account_id }}
192-
PROFILE: ${{ inputs.profile }}
193-
DEPLOY_COMMAND: ${{ inputs.deploy_command }}
194-
K8S_MANIFEST_PATH: ${{ inputs.k8s_manifest_path }}
195-
K8S_NAMESPACE: ${{ inputs.k8s_namespace }}
196-
USE_SUDO: ${{ inputs.use_sudo }}
197-
ENV_FILES_GENERATE: ${{ inputs.env_files_generate }}
198-
ENV_FILES_STRUCTURE: ${{ inputs.env_files_structure }}
199-
ENV_FILES_PATH: ${{ inputs.env_files_path }}
200-
ENV_FILES_PATTERNS: ${{ inputs.env_files_patterns }}
201-
ENV_FILES_CREATE_ROOT: ${{ inputs.env_files_create_root }}
202-
ENV_FILES_FORMAT: ${{ inputs.env_files_format }}
203-
COPY_ARTIFACTS: ${{ inputs.copy_artifacts }}
204-
GITHUB_WORKSPACE: ${{ github.workspace }}

changelogs/2026-01-29_20-04-22.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
- **Documentation Updates**: The `README.md` and `docs/env-generation.md` have been updated to reflect the new environment variable management approach and the removal of the `env_blob` input.
1313

1414
### Removed
15-
- The `env_blob` input from `action.yml` has been removed. Its functionality is now superseded by the enhanced capabilities of the `ENV` secret for passing raw environment variable blocks and templating.
15+
- The `env_blob` input from `action.yml` has been removed. Its functionality is now superseded by the enhanced capabilities of the `ENV` secret for passing raw environment variable blocks and templating.

changelogs/2026-01-29_20-18-38.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## [Unreleased]
4+
5+
### Changed
6+
- **Improved Configuration Input Handling**: The action's core script now directly retrieves GitHub Action inputs using their standard `INPUT_` prefix (e.g., `inputs.git_url` is accessed as `INPUT_GIT_URL`). This refactoring simplifies the `action.yml` definition and makes the input parsing more direct and robust.
7+
- **Internal Refactoring**: An internal variable (`env_blob_key` to `comp_env_key`) within the environment variable merging logic was renamed for improved clarity and maintainability. This change does not alter user-facing behavior.
8+
9+
### Removed
10+
- Explicit environment variable mappings for action inputs from `action.yml`. This removal is a direct consequence of the improved configuration input handling, as inputs are now read directly by the action's script.

src/config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ def get_bool_env(name, default="false"):
1414
return str(val).lower() == "true"
1515

1616
def get_env(name, default=None):
17-
return overrides.get(name) or os.getenv(name, default)
17+
# 1. Check overrides
18+
val = overrides.get(name)
19+
if val is not None:
20+
return val
21+
# 2. Check direct environment
22+
val = os.getenv(name)
23+
if val is not None:
24+
return val
25+
# 3. Check GitHub Action Input (INPUT_NAME)
26+
return os.getenv(f"INPUT_{name.upper()}") or default
1827

1928
# Configuration from environment variables
2029
self.GIT_URL_ENV = get_env("GIT_URL", "").strip()

src/env_manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,15 @@ def merge_env_vars_by_priority(
351351
merged[key] = v
352352

353353
# D. Env Specific Blob (e.g. ENV_PROD_APP)
354-
env_blob_key = f"ENV_{env_upper}_{file_base}"
355-
if env_blob_key in all_env_vars:
356-
parsed = parse_all_in_one_secret(all_env_vars[env_blob_key], config.ENV_FILES_FORMAT)
354+
comp_env_key = f"ENV_{env_upper}_{file_base}"
355+
if comp_env_key in all_env_vars:
356+
parsed = parse_all_in_one_secret(all_env_vars[comp_env_key], config.ENV_FILES_FORMAT)
357357
if parsed:
358358
for pk, pv in parsed.items():
359359
p_key = pk[len(f"{file_base}_") :] if pk.startswith(f"{file_base}_") else pk
360360
merged[p_key] = pv
361-
elif all_env_vars[env_blob_key].strip():
362-
merged[file_base] = all_env_vars[env_blob_key]
361+
elif all_env_vars[comp_env_key].strip():
362+
merged[file_base] = all_env_vars[comp_env_key]
363363

364364
return merged
365365

0 commit comments

Comments
 (0)