This action sets the current ISO8601 time to the time
output and also provides readableTime
, formattedTime
, and many more digital outputs like year
, day
, second
, etc. Useful for setting build times in subsequent steps, renaming your artifact, or keeping the same recorded time for the entire workflow.
Time format to use - using MomemtJS format syntax - optional
UTC offset to use - using MomemtJS utcOffset syntax - optional
The ISO time this action was run, not affected by the parameter utcOffset
e.g. '2020-01-01T00:30:15.000Z'
Same as time
Human-friendly time - affected by the parameter utcOffset
e.g. 'Wed Jan 01 2020 08:30:15 GMT+0800'
The time this action was run - formatted using format
and utcOffset
inputs
Digital outputs, just as names
steps:
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYYMMDD-HH
utcOffset: "+08:00"
- name: Use current time
env:
TIME: "${{ steps.current-time.outputs.time }}"
R_TIME: "${{ steps.current-time.outputs.readableTime }}"
F_TIME: "${{ steps.current-time.outputs.formattedTime }}"
YEAR: "${{ steps.current-time.outputs.year }}"
DAY: "${{ steps.current-time.outputs.day }}"
run: echo $TIME $R_TIME $F_TIME $YEAR $DAY
npm install
npm test
And you'll see the console output as following:
PASS ./action.test.js
action
√ Should load (2 ms)
√ Should run with basic functionality (2 ms)
√ Should run with format (1 ms)
√ Should run with other basic outputs (1 ms)
√ Should pass format inputs (1 ms)
√ Should throw error (1 ms)
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
All files | 100 | 100 | 100 | 100 | |
action.js | 100 | 100 | 100 | 100 |
Test Suites: 1 passed, 1 total
Tests: 6 passed, 6 total
Snapshots: 0 total
Time: 2.50 s
Ran all test suites.
npm start
And you'll see the index.js is generated in the dist folder