gpt4 book ai didi

github-actions - 在 GitHub Actions 中保存 GITHUB_ENV 变量

转载 作者:行者123 更新时间:2023-12-05 02:46:52 24 4
gpt4 key购买 nike

我正在尝试一步保存一个变量名,使用 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 }}

错误:

refs/heads/release/ is not a valid ref name.

最佳答案

我稍微更改了您的创建分支步骤,但如果您解决日期格式问题,您的 slo 应该可以工作。 enter image description here

我修改了它,它起作用了。

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 }}

这里是运行这个的日志:

enter image description here

关于github-actions - 在 GitHub Actions 中保存 GITHUB_ENV 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65287308/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com