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

Reference an external file containing the json map

Open nwaughachukwuma opened this issue 3 years ago • 4 comments

It would be nice if we can make reference to an external file containing the JSON map.

nwaughachukwuma avatar Aug 12 '21 08:08 nwaughachukwuma

It would be nice if this was supported out of the box. The simplest way I found to do it is like this:

      - id: var-map
        run: |
          echo ::set-output name=content::$(cat ./.github/env_vars.json)

      - uses: kanga333/variable-mapper@master
        id: export
        with:
          key: "key"
          map: ${{ steps.var-map.outputs.content }}
          export_to: log,output

mrmeyers99 avatar Sep 24 '21 14:09 mrmeyers99

@nwaughachukwuma Thanks for the report. And I'm sorry for the delay in replying. @mrmeyers99's workaround is very good! But, I will try to support option that read map file directly like below.

- uses: kanga333/variable-mapper@master
    id: export
    with:
      key: "key"
      map_file: "./.github/env_vars.json"
      export_to: log,output

kanga333 avatar Oct 07 '21 00:10 kanga333

OK thanks @kanga333. And thanks @mrmeyers99

nwaughachukwuma avatar Oct 08 '21 03:10 nwaughachukwuma

@mrmeyers99 I use with just passing the value as env but you can as well pass the map from output of your step

      - uses: kanga333/variable-mapper@master
        id: export
        with:
          key: "${{ env.CI_ACTION_REF_NAME }}"
          export_to: env,log,output
          map: '${{ vars.CICD_CONFIG_STRATEGY_MAPPER }}'

RafPe avatar Jun 14 '23 12:06 RafPe