Create Timestamp with GitHub Actions

Published:
Talks about: , , and

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')"

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.