我想在其中设置一个环境变量env:
GitHub Action 的部分并利用GitHub Actions 的上下文和表达式语法。我试过这个:
jobs:
build:
runs-on: ubuntu-latest
env:
MYVAR: ${{ format('{0}:{1}', ${{ env.PATH }}, ${{ env.HOME }} ) }}
steps:
- name: Check environment
run: echo $MYVAR
这会导致错误消息:
### ERRORED 10:45:52Z
- Your workflow file was invalid: The pipeline is not valid. .github/workflows/main.yml (Line: 10, Col: 14): Unexpected symbol: '${{'. Located at position 19 within expression: format('{0}:{1}', ${{ env.PATH
这个语法:
env:
MYVAR: ${{ format('{0}:{1}', {{ env.PATH }}, {{ env.HOME }} ) }}
结果出现错误:
### ERRORED 13:14:18Z
- Your workflow file was invalid: The pipeline is not valid. .github/workflows/main.yml (Line: 10, Col: 14): Unexpected symbol: '{{'. Located at position 19 within expression: format('{0}:{1}', {{ env.PATH
and:
env:
MYVAR: ${{ format('{0}:{1}', env.PATH, env.HOME ) }}
结果出现错误:
### ERRORED 13:16:12Z
- Your workflow file was invalid: The pipeline is not valid. .github/workflows/main.yml (Line: 10, Col: 14): Unrecognized named-value: 'env'. Located at position 19 within expression: format('{0}:{1}', env.PATH, env.HOME )
我知道解决方案如何在 GitHub Actions 中使用 bash 表达式设置环境变量? and Github Actions,如何在作业步骤之间共享计算值?用于设置环境变量,但我想了解表达式语法。