A Github Action for substituting variables within JSON files using env variables.
files
(required): A comma-separated list of JSON files to process. File paths are relative to the workspace root.
This action does not have any outputs.
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
{
"api_url": "${{ API_ENDPOINT }}",
"environment": "${{ ENVIRONMENT }}",
"description": "Configuration for env: ${{ ENVIRONMENT }}"
}
(Assuming your workflow defines the necessary secrets and environment variables)
{
"api_url": "https://api.example.com",
"environment": "production",
"description": "Configuration for env: production"
}