Skip to content

Error: Unexpected token *** in JSON #111

Description

@GroJooo

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 ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions