gpt4 book ai didi

github - 获取 GitHub 工作流程中的当前日期和时间

转载 作者:行者123 更新时间:2023-12-02 10:52:16 26 4
gpt4 key购买 nike

我有一个 GitHub 工作流程,用于发布存储库的夜间快照。它使用 the create-release action 。这是工作流程文件现在的样子:

name: Release Nightly Snapshot

on:
schedule:
- cron: "0 0 * * *"

jobs:
build:
name: Release Nightly Snapshot
runs-on: ubuntu-latest
steps:
- name: Checkout master Branch
uses: actions/checkout@v2
with:
ref: 'master'
- name: Create Release
id: nightly-snapshot
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: 'nightly snapshot'
release_name: 'nightly snapshot'
draft: false
prerelease: false

我希望 tag_namerelease_name 使用当前日期和时间,而不是硬编码值。但是,我找不到任何有关它的文档。我该怎么做?

最佳答案

来自this post您可以创建一个步骤 set its output值为 $(date +'%Y-%m-%d')

然后使用 ${{steps.date.outputs.date }} 使用此输出。下面显示了环境变量和输入的示例:

on: [push, pull_request]
name: build
jobs:
build:
name: Example
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Test with environment variables
run: echo $TAG_NAME - $RELEASE_NAME
env:
TAG_NAME: nightly-tag-${{ steps.date.outputs.date }}
RELEASE_NAME: nightly-release-${{ steps.date.outputs.date }}
- name: Test with input
uses: actions/hello-world-docker-action@master
with:
who-to-greet: Mona-the-Octocat-${{ steps.date.outputs.date }}

输出:

* Test with environment variables
nightly-tag-2020-03-31 - nightly-release-2020-03-31

* Test with input
Hello Mona-the-Octocat-2020-03-31

关于github - 获取 GitHub 工作流程中的当前日期和时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60942067/

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