本文介绍了在GitHub操作中保存GitHub_ENV变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用date在一个步骤中保存变量名。但是,在后面的步骤中,它似乎是未定义的(或空的?)。我在这里错过了什么?
jobs:
# Create release branch for the week
branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Format the date of next Tuesday
id: tuesday
run: echo "abbr=$(date -v+tuesday +'%y%m%d')" >> $GITHUB_ENV
- name: Create a branch with next tuesday's date
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: release/${{ steps.tuesday.outputs.abbr }}
错误:
refs/heads/release/ is not a valid ref name.
推荐答案
我稍微更改了您的创建分支步骤,但如果您解决了日期格式问题,您的SLO应该可以工作。
我更改了它,它起作用了。
jobs:
# Create release branch for the week
branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Format the date of next Tuesday
id: tuesday
run: echo "abbr=$(date '+tuesday%y%m%d')" >> $GITHUB_ENV
- name: Read exported variable
run: |
echo "$abbr"
echo "${{ env.abbr }}"
- name: Create a branch with next tuesday's date
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: release/${{ env.abbr }}
这里是运行以下命令的日志:
这篇关于在GitHub操作中保存GitHub_ENV变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!