Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/josstorer/get-current-time
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.
https://github.com/josstorer/get-current-time
actions github-actions
Last synced: about 1 month ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/josstorer/get-current-time
- Owner: josStorer
- License: mit
- Created: 2020-03-02T08:00:08.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-19T18:51:44.000Z (10 months ago)
- Last Synced: 2024-11-10T16:48:13.396Z (about 2 months ago)
- Topics: actions, github-actions
- Language: JavaScript
- Homepage:
- Size: 2.16 MB
- Stars: 38
- Watchers: 2
- Forks: 21
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Test the action workflow](https://github.com/josStorer/get-current-time/workflows/Test%20the%20action/badge.svg)](https://github.com/josStorer/get-current-time/actions?query=workflow:"Test+the+action")
[![Codecov](https://codecov.io/gh/josStorer/get-current-time/graph/badge.svg)](https://codecov.io/gh/josStorer/get-current-time)
[![GitHub release](https://img.shields.io/github/release/josStorer/get-current-time.svg)](https://github.com/josStorer/get-current-time/releases/latest)
[![GitHub marketplace](https://img.shields.io/badge/marketplace-get--current--time-blue?logo=github)](https://github.com/marketplace/actions/get-current-time)
[![Repo contributors](https://img.shields.io/github/contributors/josStorer/get-current-time.svg)](https://github.com/josStorer/get-current-time/graphs/contributors)
[![Open issues](https://img.shields.io/github/issues-raw/josStorer/get-current-time)](https://github.com/josStorer/get-current-time/issues?q=is%3Aissue+is%3Aopen)
[![Solved issues](https://img.shields.io/github/issues-closed-raw/josStorer/get-current-time/solved?color=4bc51d&label=solved%20issues)](https://github.com/josStorer/get-current-time/issues?q=is%3Aissue+label%3Asolved)# Get Current Time Github Action
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.You can view some typical input/output in the [action.test.js](./action.test.js) file.
## Inputs
### `format`
Time format to use - using [MomentJS format syntax](https://momentjs.com/docs/#/displaying/format/) - optional
### `utcOffset`
UTC offset to use - using [MomentJS utcOffset syntax](https://momentjs.com/docs/#/manipulating/utc-offset/) - optional
### `timezone`
Timezone to use - check [moment-timezone list](https://gist.github.com/diogocapela/12c6617fc87607d11fd62d2a4f42b02a) -
optional, if set, utcOffset will be ignored, e.g. "America/Los_Angeles"## Outputs
### `time`
The ISO time this action was run, **not** affected by the parameter `utcOffset` e.g. '2020-01-01T00:30:15.000Z'
### `ISOTime`
Same as `time`
### `readableTime`
Human-friendly time - affected by the parameter `utcOffset` e.g. 'Wed Jan 01 2020 08:30:15 GMT+0800'
### `formattedTime`
The time this action was run - formatted using `format` and `utcOffset` inputs
### `year,month,day,hour,minute,second,millisecond`
Digital outputs, just as names
## Example usage
```yaml
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
```## Run locally
### First
```
npm install
```### Build
```
npm start
```And you'll see the index.js is generated in the dist folder
### Test
```
npm test
```And you'll see the console output as following:
***
**PASS** ./action.test.js
action
**√** Should load (1 ms)
**√** Should correctly set outputs (1 ms)
**√** Should correctly set outputs with utcOffset (1 ms)
**√** Should correctly set outputs with timezone (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: **5 passed**, 5 total
Snapshots: 0 total
Time: 1 s
Ran all test suites.
***
## Credit
This project is forked from [srfrnk/current-time](https://github.com/srfrnk/current-time) and detached since 14 December
of 2022