Simple Action to generate a "build tag" based on workflow variables. For use in tags, Docker images, etc.
The Action uses workflow variables from the context and runs them through a tag generation routine based on a template, yielding a build tag as a result.
Required: yes
The tag template. Elements are enclosed in curly brackets { }
. Valid elements are:
runId
: FromGITHUB_RUN_ID
runNumber
: FromGITHUB_RUN_NUMBER
sha
: FromGITHUB_SHA
shortSha
: FromGITHUB_SHA
, but truncated toshortShaLength
time
: Current time. The format used can be specified with the inputtimeFormat
.refName
: FromGITHUB_REF_NAME
For more information around the values, see docs
Valid example format: {time}-{runId}-{sha}
Required: no. Default: YYYYMMDDHHmm
Time format specifier follows that of moment.js
Required: no. Default: 7
When using shortSha
, sets the number of characters of the full SHA to use.
The resulting generated tag, ready for use.
name: example
on: [push]
jobs:
generate_tag:
runs-on: ubuntu-latest
steps:
- name: Generate build tag
id: build_tag
uses: erikns/buildtag-action@v1
with:
template: "{time}-{runId}-{shortSha}"
timeFormat: "YYYY-MM-DD-HHmm"
shortShaLength: 8
- name: Use build tag
run: echo ${{ steps.build_tag.outputs.tag }}
- Add unit tests
Simple, permissive MIT License.