GitHub Actions中的GITHUB_ENV变量 [英] GITHUB_ENV Variable in GitHub Actions

查看:183
本文介绍了GitHub Actions中的GITHUB_ENV变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用

我更改了它,并且可以正常工作.

 职位:#创建一周的发布分支分支:运行:ubuntu-latest脚步:-用途:actions/checkout @ v2-名称:格式化下周二的日期id:星期二运行:echo"abbr = $(date'+ tuesday%y%m%d')">>$ GITHUB_ENV-名称:读取导出的变量运行:回声"$ abbr"回声"$ {{env.abbr}}"-名称:使用下一个星期二的日期创建一个分支用途:peterjgrainger/action-create-branch@v2.0.1环境:GITHUB_TOKEN:$ {{secrets.GITHUB_TOKEN}}和:分支:release/$ {{env.abbr}} 

这是运行此命令的日志:

I'm trying to save a variable name in one step, using date. But, in a later step, it seems to be undefined (or empty?). What am I missing 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 -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 }}

Error:

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

解决方案

I slightly changed your create branch step but your slo should work if you solve issue with date formatting.

I changed it and it works.

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

Here a logs from running this:

这篇关于GitHub Actions中的GITHUB_ENV变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆