/variable-substitution

Github action for variable substitution

Primary LanguagePythonGNU General Public License v2.0GPL-2.0

Integration Test License

variable-substitution

A Github Action for substituting variables within JSON files using env variables.


Inputs

  • files (required): A comma-separated list of JSON files to process. File paths are relative to the workspace root.

Outputs

This action does not have any outputs.


Usage Example

Workflow that uses the action

jobs:
  my_job:
    env:
      ENVIRONMENT: production
      API_ENDPOINT: https://api.example.com
    
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Substitute Variables
        uses: mattcollie/variable-substitution@v1
        with:
          files: config.json

Original config.json:

{
  "api_url": "${{ API_ENDPOINT }}",
  "environment": "${{ ENVIRONMENT }}",
  "description": "Configuration for env: ${{ ENVIRONMENT }}"
}

After Substitution:

(Assuming your workflow defines the necessary secrets and environment variables)

{
  "api_url": "https://api.example.com",
  "environment": "production",
  "description": "Configuration for env: production"
}