Create Timestamp with GitHub Actions
Published:
, Updated:
Talks about:
<a class="post-tag post-tag-github" href="/tags/github">github</a>, <a class="post-tag post-tag-github-actions" href="/tags/github-actions">github actions</a>, and <a class="post-tag post-tag-timestamp" href="/tags/timestamp">timestamp</a>
In case you are into calver or have another reason to create a timestamp with GitHub Actions, do the following:
name: <PIPELINE>
jobs:
build:
runs-on: <RUN_ON>
steps:
- name: Create release version
id: <ID>
run: echo "::set-output name=<NAME>::$(date +'%Y.%m.%d-%H%M%S')"
<PIPELINE>
: The name of your pipeline.<RUN_ON>
: The runner to use, see GitHub’s own documentation for possible values.<ID>
: The unique ID of the timestamp step.<NAME>
: The name of the created timestamp.
The special syntax ::set-output name=<NAME>::
declares that the output of the command (echo
) should be saved in a variable called <NAME>
. Together with the <ID>
of the pipeline step, this value can be referenced with the expression ${{ steps.<ID>.outputs.<NAME> }}
in the following steps of your pipeline.