Using variable-mapper in my workflow, I'm trying to map secrets and host depending on a workflow input named environment. Partial yaml file is as follows :
workflow_dispatch:
inputs:
environment:
required: true
default: 'test'
type: choice
description: Which environment ?
options:
- test
- staging
- prod
build_assets:
required: false
type: boolean
description: Build assets ?
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Project Checkout
uses: actions/checkout@v3
- name: Node version Setup
uses: actions/setup-node@v3
with:
node-version: '18.17.1'
cache: 'npm'
- name: Map environment variables
uses: kanga333/variable-mapper@master
with:
key: "${{inputs.environment}}"
map: |
{
"prod": {
"environment": "production",
"AWS_SECRET_ACCESS_KEY": "${{ secrets.SSH_PRIVATE_KEY }}"
},
"staging": {
"environment": "staging",
"AWS_SECRET_ACCESS_KEY": "${{ secrets.SSH_PRIVATE_KEY_STAGING }}"
},
".*": {
"environment": "test",
"AWS_SECRET_ACCESS_KEY": "${{ secrets.SSH_PRIVATE_KEY_TEST }}"
}
}
- name: Echo environment
run: echo ${{ env.environment }}
My worflow fails with following error:
with:
key: test
map: {
"prod": {
"environment": "production",
"AWS_SECRET_ACCESS_KEY": "***"
},
"staging": {
"environment": "staging",
"AWS_SECRET_ACCESS_KEY": "***"
},
".*": {
"environment": "test",
"AWS_SECRET_ACCESS_KEY": "***"
}
}
export_to: log,env
mode: first_match
Error: Unexpected token
in JSON at position 108
I've already checked that my map JSON is correct, I don't get what I'm missing here. Looks like there is a special character somewhere, by it don't see any. Can somebody help me ?