variable-mapper icon indicating copy to clipboard operation
variable-mapper copied to clipboard

Error: Unexpected token *** in JSON

Open GroJooo opened this issue 10 months ago • 0 comments

Hi everyone, In my build-and-deploy.yml workflow, I have the following:

on:
  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:

Run kanga333/variable-mapper@master
  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 Can somebody help me ?

GroJooo avatar Mar 29 '24 09:03 GroJooo