根据版本重命名文件
我试图在标记新版本时重命名文件,但失败了。
- name: rename file
run: mv ./Code/.pio/build/attiny841/firmware.hex ./Code/.pio/build/attiny841/megadesk-${{ $GITHUB_REF_NAME }}.hex
但是,当它运行时,我会收到错误
Invalid workflow file: .github/workflows/version_pio_build.yml#L44
The workflow is not valid. .github/workflows/version_pio_build.yml (Line: 44, Col: 12): Unexpected symbol: '$GITHUB_REF_NAME'. Located at position 1 within expression: $GITHUB_REF_NAME
如果我将其更改为
- name: rename file
run: mv ./Code/.pio/build/attiny841/firmware.hex ./Code/.pio/build/attiny841/megadesk-${{ env.GITHUB_REF_NAME }}.hex
那么结果执行是 mv ./Code/.pio/build/attiny841/firmware.hex ./Code/.pio/build/attiny841/megadesk-.hex
请注意,这是在标签推送时触发的。
- name: env list
run: env
这有一个变量列表,包括
...
RUNNER_TOOL_CACHE=/opt/hostedtoolcache
ImageVersion=20220220.1
DOTNET_NOLOGO=1
GITHUB_REF_NAME=v25
GRAALVM_11_ROOT=/usr/local/graalvm/graalvm-ce-java11-22.0.0.2
GITHUB_JOB=build
AZURE_EXTENSION_DIR=/opt/az/azcliextensions
...
I'm trying to rename a file when a new release is tagged, but it is failing.
- name: rename file
run: mv ./Code/.pio/build/attiny841/firmware.hex ./Code/.pio/build/attiny841/megadesk-${{ $GITHUB_REF_NAME }}.hex
However when it runs I get an error
Invalid workflow file: .github/workflows/version_pio_build.yml#L44
The workflow is not valid. .github/workflows/version_pio_build.yml (Line: 44, Col: 12): Unexpected symbol: '$GITHUB_REF_NAME'. Located at position 1 within expression: $GITHUB_REF_NAME
If I change this to
- name: rename file
run: mv ./Code/.pio/build/attiny841/firmware.hex ./Code/.pio/build/attiny841/megadesk-${{ env.GITHUB_REF_NAME }}.hex
Then the resulting execution ismv ./Code/.pio/build/attiny841/firmware.hex ./Code/.pio/build/attiny841/megadesk-.hex
Note this is triggered on a tag push.
- name: env list
run: env
This has a list of variables including
...
RUNNER_TOOL_CACHE=/opt/hostedtoolcache
ImageVersion=20220220.1
DOTNET_NOLOGO=1
GITHUB_REF_NAME=v25
GRAALVM_11_ROOT=/usr/local/graalvm/graalvm-ce-java11-22.0.0.2
GITHUB_JOB=build
AZURE_EXTENSION_DIR=/opt/az/azcliextensions
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里的问题是您使用了错误的语法。
${{ $GITHUB_REF_NAME }}
和${{ env.GITHUB_REF_NAME }}
都不起作用,但只有$GITHUB_REF_NAME
可以。因此,您的命令行应该是:
如果您想看一下,这里有一个演示:
工作流程文件:https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/workflows/49-rename-on-release.yml
工作流程运行:https://github.com/GuillaumeFalourd/poc-github-actions/runs/5359686796?check_suite_focus=true
Your problem here is that you used the wrong syntax.
Neither
${{ $GITHUB_REF_NAME }}
nor${{ env.GITHUB_REF_NAME }}
will work, but just$GITHUB_REF_NAME
will.Therefore, your command line should be:
If you want to take a look, here is a demo:
Workflow file: https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/workflows/49-rename-on-release.yml
Workflow run: https://github.com/GuillaumeFalourd/poc-github-actions/runs/5359686796?check_suite_focus=true