A GitHub Action that replaces __TOKENS__ with environment variables in files. Drop-in replacement for falnyr/replace-env-vars-action with safe handling of special characters (|, &, /, \, $, etc.) in values.
- name: Replace tokens
uses: sushidev-team/workflow-var-action@master
with:
filename: k8/deployment.yml
env:
PROJECT: ${{ vars.PROJECT }}
APP_ENV: ${{ vars.APP_ENV }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
API_TOKEN: ${{ secrets.API_TOKEN }}Given a file with placeholders:
metadata:
name: __PROJECT__-config-__APP_ENV__
data:
DB_PASSWORD: __DB_PASSWORD__
API_TOKEN: "__API_TOKEN__"The action replaces all __VAR__ patterns with the corresponding environment variable values:
metadata:
name: myapp-config-stage
data:
DB_PASSWORD: p@ss|w0rd&special/chars
API_TOKEN: "token|with|pipes"| Name | Required | Description |
|---|---|---|
filename |
Yes | Path to the file to process |
- Scans the file for
__PLACEHOLDER__patterns - Replaces each placeholder with the matching environment variable
- Unmatched placeholders are left untouched
- Uses Node.js string replacement (no
sed) so special characters in values are handled safely
Replace the uses line — everything else stays the same:
- uses: falnyr/replace-env-vars-action@master
+ uses: sushidev-team/workflow-var-action@masternpm install
npm test