我正在尝试使用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/action-create-branch@v2.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: release/${{ steps.tuesday.outputs.abbr }}
Run Code Online (Sandbox Code Playgroud)
错误:
refs/heads/release/ is not a valid ref name.
Run Code Online (Sandbox Code Playgroud)
我稍微改变了您的创建分支步骤,但如果您解决日期格式问题,您的 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/action-create-branch@v2.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: release/${{ env.abbr }}
Run Code Online (Sandbox Code Playgroud)
这是运行此命令的日志:
| 归档时间: |
|
| 查看次数: |
8142 次 |
| 最近记录: |