Skip to content

Commit 1f8d9f9

Browse files
committed
added time formatting
1 parent de1b685 commit 1f8d9f9

File tree

7 files changed

+34
-12
lines changed

7 files changed

+34
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ The UTC time when this step was run.
1212

1313
```yaml
1414
steps:
15-
- name: Get current time
16-
uses: gerred/actions/current-time@master
17-
id: current-time
18-
- name: Use current time
19-
env:
20-
TIME: "${{ steps.current-time.outputs.time }}"
21-
run: echo $TIME
22-
```
15+
- name: Get current time
16+
uses: srfrnk/current-time@master
17+
id: current-time
18+
with:
19+
format: YYYYMMDD
20+
- name: Use current time
21+
env:
22+
TIME: "${{ steps.current-time.outputs.time }}"
23+
F_TIME: "${{ steps.current-time.outputs.formattedTime }}"
24+
run: echo $TIME $F_TIME
25+
```

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ description: "Get the current time with format"
44
branding:
55
icon: clock
66
color: blue
7+
inputs:
8+
format:
9+
description: "Time format to use using [MomemtJS syntax](https://momentjs.com/)"
10+
default: "<None>"
711
outputs:
812
time:
913
description: "The time this action was run"
14+
formattedTime:
15+
description: "The time this action was run - formatted using `format` input"
1016
runs:
1117
using: "node12"
1218
main: "index.js"

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
const core = require("@actions/core");
22
const github = require("@actions/github");
3+
var moment = require('moment');
34

45
try {
56
const time = new Date().toISOString();
67
core.setOutput("time", time);
8+
9+
const format = core.getInput('format', { required: false });
10+
core.setOutput("formattedTime", moment().format(format));
711
} catch (error) {
812
core.setFailed(error.message);
913
}

node_modules/.yarn-integrity

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "current-time",
3-
"version": "1.0.0a",
3+
"version": "1.1.0",
44
"main": "index.js",
55
"license": "Apache-2.0",
66
"dependencies": {
77
"@actions/core": "^1.1.0",
8-
"@actions/github": "^1.1.0"
8+
"@actions/github": "^1.1.0",
9+
"momentjs": "^2.0.0"
910
}
1011
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ macos-release@^2.2.0:
170170
resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.3.0.tgz#eb1930b036c0800adebccd5f17bc4c12de8bb71f"
171171
integrity sha512-OHhSbtcviqMPt7yfw5ef5aghS2jzFVKEFyCJndQt2YpSQ9qRVSEv2axSJI1paVThEu+FFGs584h/1YhxjVqajA==
172172

173+
momentjs@^2.0.0:
174+
version "2.0.0"
175+
resolved "https://registry.yarnpkg.com/momentjs/-/momentjs-2.0.0.tgz#73df904b4fa418f6e3c605e831cef6ed5518ebd4"
176+
integrity sha1-c9+QS0+kGPbjxgXoMc727VUY69Q=
177+
173178
nice-try@^1.0.4:
174179
version "1.0.5"
175180
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"

0 commit comments

Comments
 (0)