Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rewrite just with linux date fn #4

Merged
merged 2 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [10]

steps:
- name: Checkout Git Source
uses: actions/checkout@v1

- name: test1
id: time1
uses: nanzm/get-time-action@v1.1
uses: ./

- name: test1-output
env:
Expand All @@ -28,9 +27,9 @@ jobs:

- name: test2
id: time2
uses: nanzm/get-time-action@v1.1
uses: ./
with:
timeZone: 8
timeZone: UTC+8
format: 'YYYY-MM-DD_HH:mm:ss'

- name: test2-output
Expand Down
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MIT License
# MIT License

Copyright (c) 2022 BoredLand
Copyright (c) 2019 JantHsueh

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Get the time in the specified time zone
```yaml
- name: Get Time
id: time
uses: nanzm/get-time-action@v1.1
uses: boredland/get-time-action@master
with:
timeZone: 8
timeZone: UTC+8
format: 'YYYY-MM-DD-HH-mm-ss'
- name: Usage
env:
Expand All @@ -22,18 +22,15 @@ Get the time in the specified time zone

| Parameter | Required | Info |
| ---------- | -------- | ------------------------------------------------------------ |
| `timeZone` | `false` | time Zone Default: 0 |
| `format` | `false` | timestamp format string Default: '' |

| `timeZone` | `false` | time Zone Default: UTC |
| `format` | `false` | timestamp format string Default: |

## Outputs

| Parameter | Info |
| ---------- | ------------------------------------------------------------ |
| `time` | time in the specified time zone|



## License

[MIT](LICENSE)
27 changes: 21 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
name: 'Get Timestamp Action'
description: 'Get the time in the specified time zone'
author: 'nanzm'
author: 'boredland'
branding:
icon: arrow-right-circle
color: gray-dark
inputs:
timeZone:
description: 'time zone'
description: 'linux time zone'
required: false
default: 0
default: 'UTC'
format:
description: 'timestamp format'
required: false
default: ''
default: 'YYYY-MM-DD HH:mm:ss'
outputs:
time:
description: 'current time'
value: ${{ steps.time.outputs.value }}
runs:
using: 'node16'
main: 'dist/index.js'
using: "composite"
steps:
- id: time
shell: bash
env:
TZ: ${{ inputs.timeZone }}
run: |
TEMPLATE="${{ inputs.format }}"
TEMPLATE=${TEMPLATE/YYYY/%Y}
TEMPLATE=${TEMPLATE/MM/%m}
TEMPLATE=${TEMPLATE/DD/%d}
TEMPLATE=${TEMPLATE/HH/%H}
TEMPLATE=${TEMPLATE/mm/%M}
TEMPLATE=${TEMPLATE/ss/%S}
DATE=$(date +"$TEMPLATE")
echo "value=$DATE" >> $GITHUB_OUTPUT
7 changes: 0 additions & 7 deletions demo.js

This file was deleted.