Skip to content

Commit

Permalink
✨ Add support for custom timezone
Browse files Browse the repository at this point in the history
Defaults to America/New_York
  • Loading branch information
mikesprague authored Sep 21, 2021
1 parent 703c04c commit 3423e94
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ Include anywhere in steps to notify when workflow run is successful
- **default:** `false`
- **description:** Sends a workflow notification that is built dynamically from commit and repo info
- **example:** `deploy-card: true`
- `timezone`
- **required:** false
- **type:** string
- **default:** `"America/New_York"`
- **description:** Timezone to use for timestamps in messages
- **example:** `timezone: "Europe/Rome"`

## Future Plans

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inputs:
description: "Send a GitHub deploy notification"
required: false
default: false
timezone:
description: "Timezone for message timestamps"
required: false
default: 'America/New_York'
runs:
using: "node12"
main: "dist/index.js"
13 changes: 9 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ const dayjs = require('dayjs');
const timezone = require('dayjs/plugin/timezone');
const utc = require('dayjs/plugin/utc');

dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.tz.setDefault('America/New_York');

const { getHexForColorString } = require('./lib/helpers');

const run = async () => {
Expand Down Expand Up @@ -47,9 +43,18 @@ const run = async () => {
required: false,
trimWhitespace: true,
}) || false;
const timezoneString =
core.getInput('timezone', {
required: false,
trimWhitespace: true,
}) || 'America/New_York';

const colorString = getHexForColorString(color);

dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.tz.setDefault(timezoneString);

let messageToPost;
if (isDeployCard) {
const { populateCard } = require('./lib/cards/deploy');
Expand Down

0 comments on commit 3423e94

Please sign in to comment.