Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Value altered when substitude value in yaml #40

@xunjieliu

Description

@xunjieliu

How to reproduce

Here is part of my workflow script

      - name: Variable substitution
        uses: microsoft/variable-substitution@v1
        with:
          files: ./build/config.yaml
        env:
          sms.senderNumber: ${{ secrets.SMS_SENDER_NUMBER }}

And secrets.SMS_SENDER_NUMBER is 1069368924410002259

But when the workflow is done, I check the actual config file, I got this

image

The value is not the same as secrets.SMS_SENDER_NUMBER

What I have done to solve this

Check if GitHub secret correct

I use the following workflow debug GitHub action via ssh:

name: Show Me the S3cr3tz
on: [push]

jobs:
  debug:
    name: Debug
    runs-on: ubuntu-latest

    steps:
    - name: Check out code
      uses: actions/checkout@v2

    - name: Set up secret file
      env:
        SMS_SENDER_NUMBER: ${{ secrets.SMS_SENDER_NUMBER }}
      run: |
        echo $SMS_SENDER_NUMBER >> secrets.txt

    - name: Run tmate
      uses: mxschmitt/action-tmate@v2

The secret value is correct

Direct write value to the workflow YAML file

      - name: Variable substitution
        uses: microsoft/variable-substitution@v1
        with:
          files: ./build/config.yaml
        env:
          sms.senderNumber: 1069368924410002259

The result is, that the value is still altered,

Use double quotes

      - name: Variable substitution
        uses: microsoft/variable-substitution@v1
        with:
          files: ./build/config.yaml
        env:
          sms.senderNumber: "1069368924410002259"

The result is, that the value is still altered,

Use sed command

      - name: Replace sender number
        run: sed -i 's/SMS_SENDER_NUMBER/${{ secrets.SMS_SENDER_NUMBER }}/' ./build/config.yaml

The result shows that the replacement is done correctly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions