在 GitHub Actions 中保存 GITHUB_ENV 变量

2024-01-07

我正在尝试一步保存变量名称,使用date https://man7.org/linux/man-pages/man1/date.1.html。但是,在后面的步骤中,它似乎是未定义的(或空的?)。我在这里缺少什么?

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] /cdn-cgi/l/email-protection
        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. 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/[email protected] /cdn-cgi/l/email-protection
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          branch: release/${{ env.abbr }}

这是运行此命令的日志:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 GitHub Actions 中保存 GITHUB_ENV 变量 的相关文章

随机推荐