Environment variables in CI/CD workflows should be organized consistently using structured `env` sections rather than inline declarations, and should account for platform-specific requirements. This improves maintainability, readability, and prevents environment-related failures across different operating systems.
Environment variables in CI/CD workflows should be organized consistently using structured env
sections rather than inline declarations, and should account for platform-specific requirements. This improves maintainability, readability, and prevents environment-related failures across different operating systems.
Use the env
field at the step or job level instead of inline variable assignments:
# Preferred approach
- name: Package and Publish Extension
env:
VSCE_PAT: $
OVSX_PAT: $
CLINE_ENVIRONMENT: production
run: vsce package --out "cline-$.vsix"
# Instead of inline
run: CURRENT_ENVIRONMENT=production vsce package --out "file.vsix"
For cross-platform compatibility, explicitly set platform-specific environment variables when needed:
run: |
# Default the encoding to UTF-8 - It's not the default on Windows
PYTHONUTF8=1 PYTHONPATH=.github/scripts python -m coverage_check
This approach centralizes environment configuration, makes dependencies explicit, and prevents platform-specific failures in automated workflows.
Enter the URL of a public GitHub repository