How to get the current time as an environment variable in actions? #26342
-
I hope to automatically create a new release through Actions and set the name to the current time, but I have failed many times. How can I do this? |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
Assuming your build is running on Linux, you can just use the
That’ll give you the current date in YYYY-MM-DD format, adjust the |
Beta Was this translation helpful? Give feedback.
-
It’s failed. Maybe my configuration is wrong? |
Beta Was this translation helpful? Give feedback.
-
It looks like you’re sending the date into
Workflow commands for GitHub Actions - GitHub Docs |
Beta Was this translation helpful? Give feedback.
-
You’ll likely need to wrap it in an expression syntax, otherwise it’ll just output as a string:
|
Beta Was this translation helpful? Give feedback.
-
All right.It’s now working. |
Beta Was this translation helpful? Give feedback.
It looks like you’re sending the date into
${TIME}
instead of$GITHUB_ENV
. To set an environment variable you need to send it to$GITHUB_ENV
in the following format:echo "{name}={value}" >> $GITHUB_ENV
docs.github.com
Workflow commands for GitHub Actions - GitHub Docs