variable-mapper
variable-mapper copied to clipboard
Reference an external file containing the json map
It would be nice if we can make reference to an external file containing the JSON map.
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
@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
OK thanks @kanga333. And thanks @mrmeyers99
@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 }}'