在YAML文件中导入一个JS函数。

huangapple go评论88阅读模式
英文:

Import a JS function inside of YAML file

问题

github-workflow.yaml

variables:
  message: computeTheString()

name: My Trigger
on:
  pull_request_target:
    types: [labeled]

jobs:
  publish:
    runs-on: [default]

    steps:
      - name: Step name here
        run: echo ${{ variables.message }}

computeTheString.js

export function computeTheString() {
    return JSON.stringify(slightlyLongerString);
}
英文:

I'm trying to pass custom variable inside of yaml file which will be computed in a separate file.

Is there a way I can do that?

github-workflow.yaml

variable:
  message: computeTheString()

name: My Trigger
on:
  pull_request_target:
    types: [labeled]

jobs:
  publish:
    runs-on: [ default ]

    steps:
      - name: Step name here
        run: echo ${{ variable. message }}

computeTheString.js

export function computeTheString() {
    return JSON.stringify(slightlyLongerString)
}

答案1

得分: 1

你可以尝试使用管道符号(|),它表示多行输入。这里是一个使用内联函数的CloudFormation示例:

variables:
  message: |
    export function computeTheString() {
      return JSON.stringify(slightlyLongerString);
    }    

示例链接

英文:

You could try to use the pipe symbol (|) which indicates a multi-line entry. here's an example of CloudFormation with inline function:

variable:
  message: |
    export function computeTheString() {
      return JSON.stringify(slightlyLongerString)
    }

huangapple
  • 本文由 发表于 2023年7月18日 05:25:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76708170.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定