Skip to content

Commit

Permalink
supporting user input timezone for release date
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin-JHG committed May 15, 2023
1 parent 841f986 commit 9cb03d4
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 33 deletions.
76 changes: 54 additions & 22 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,58 @@
name: 🍺 sync
name: 🍺 sync

# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for listed branches
push:
branches: [main]

workflow_dispatch:

# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for listed branches
push:
branches: [main]

# Cancel the current run if a new run is triggered
concurrency:
group: CI-${{ github.ref }}-1
cancel-in-progress: true
# Cancel the current run if a new run is triggered
concurrency:
group: CI-${{ github.ref }}-1
cancel-in-progress: true

jobs:
createPullRequest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: create pull request
jobs:
createPullRequest:

runs-on: ubuntu-latest

steps:

- name: Checkout code
uses: actions/checkout@v3
with:
ref: feature/melbourne-time-zone

- name: Set git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "justin-jhg"
- name: Merge Changes from Master to Melbourne Branch
continue-on-error: true
run: |
git push origin --delete Melbourne
git checkout -b Melbourne
git push --set-upstream origin Melbourne
git pull
git merge -X theirs origin/main --allow-unrelated-histories --no-edit
- name: Rebuild Melbourne Branch
run: |
git checkout -b syncFromMain
git push --set-upstream origin syncFromMain
gh pr create -B feature/melbourne-time-zone -H syncFromMain --title 'Merge main into melbourne-time-zone' --body 'Created by Github action'
npm install all
npm run all
git add .
git commit -m "Rebuild Melbourne branch"
git push
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "merge changes into melbourne-time-zone" \
--body "This pull request was automatically created by a GitHub Action to merge the latest changes main branch" \
--base feature/melbourne-time-zone \
--head Melbourne
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
jira_api_token: foobar
jira_base_url: http://
jira_project: PROJ
release_name: New Release Name
release_name: New Release Name
time_zone: Australia/Melbourne
release: false
create: true
archive: true
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

This Github action connects your CI and your Jira instance by creating release(Fix Version) and assign Jira issues to the release as part of your CI process.

- Create a JIRA release (Fix Version), release date will be today's date in UTC.
- Assign JIRA Issue Key to the release (Fix Version)
- Release can be created as archived as well
- Create a JIRA release, release date supports timezone overwrite.
- Assign JIRA Issues to release
- Achive a JIRA release


## Usage
Expand All @@ -20,7 +20,7 @@ jobs:
name: Release Jira Fix Version
runs-on: ubuntu-latest
steps:
uses: justin-jhg/jira-release-actions@v1.0
uses: justin-jhg/jira-release-actions@v1
with:
jira_base_url: ${{ secrets.JIRA_BASE_URL }}
jira_user_email: ${{ secrets.JIRA_USER_EMAIL }}
Expand All @@ -30,6 +30,7 @@ jobs:
tickets: CI-123,CI-456
release: true
archive: false
time_zone: Australia/Melbourne
```
----
Expand All @@ -45,6 +46,7 @@ jobs:
| jira_user_email | email of the user for which **Access Token** was created for . Example: `[email protected]` | Yes | String |
| jira_project | Key of the jira project | Yes | String |
| release_name | Name of the release (Fix Version) | Yes | String |
| time_zone | timezone for release date to be set, e.g. Australia/Melbourne, default is UTC time | No | String |
| release | Mark Jira fix version as released. Defaults to false. | No | Boolean |
| archive | Mark Jira fix version as archived. Defaults to false. | No | Boolean |
| tickets | Comma-separated list of Jira Issue Keys to include in the release. Defaults to ''. | No | String |
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
release_name:
description: Name of the release, fix version
required: true
time_zone:
description: timezone used for setting release date, default UTC
default: 'England/Greenwich'
required: false
release:
description: 'Create the version as released'
default: 'false'
Expand All @@ -41,7 +45,6 @@ inputs:
default: 'false'
required: false


runs:
using: 'node16'
main: 'dist/index.js'
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const SUBDOMAIN: string = getInput('jira_base_url', { required: true })

// Release information
export const RELEASE_NAME: string = getInput('release_name', { required: true })
export const TIME_ZONE: string = getInput('time_zone', { required: false })
export const PROJECT: string = getInput('jira_project', { required: true })
export const TICKETS: string = getInput('tickets', { required: false })

Expand Down
22 changes: 19 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { info, setFailed } from '@actions/core'
import { EMAIL, API_TOKEN, SUBDOMAIN, RELEASE_NAME, PROJECT, CREATE, TICKETS, DRY_RUN, RELEASE, ARCHIVE } from './env'
import {
EMAIL,
API_TOKEN,
SUBDOMAIN,
RELEASE_NAME,
TIME_ZONE,
PROJECT,
CREATE,
TICKETS,
DRY_RUN,
RELEASE,
ARCHIVE
} from './env'
import { API } from './api'
import * as DebugMessages from './constants/debug-messages'
import { CreateVersionParams, UpdateVersionParams } from './types'
Expand All @@ -11,6 +23,7 @@ const printConfiguration = (): void => {
* project: ${PROJECT}
* subdomain: ${SUBDOMAIN}
* release_name: ${RELEASE_NAME}
* time_zone: ${TIME_ZONE}
* create: ${CREATE}
* tickets: ${TICKETS}
* release: ${RELEASE}
Expand Down Expand Up @@ -46,6 +59,9 @@ async function run(): Promise<void> {
const release = RELEASE === true
const archive = ARCHIVE === true

const localDateString = new Date().toLocaleString('en-US', { timeZone: TIME_ZONE })
const localISOString = new Date(localDateString).toISOString()

if (version === undefined) {
// Create new release and ignore ARCHIVE value
info(DebugMessages.VERSION_NOT_FOUND(RELEASE_NAME))
Expand All @@ -57,7 +73,7 @@ async function run(): Promise<void> {
name: RELEASE_NAME,
released: release === true && archive !== true,
projectId: Number(project.id),
...(release && { releaseDate: new Date().toISOString() }),
...(release && { releaseDate: localISOString }),
archived: false
}

Expand All @@ -70,7 +86,7 @@ async function run(): Promise<void> {

const versionToUpdate: UpdateVersionParams = {
released: release,
...(release && { releaseDate: new Date().toISOString() }),
...(release && { releaseDate: localISOString }),
archived: false
}
version = await api.updateVersion(version.id, versionToUpdate)
Expand Down

0 comments on commit 9cb03d4

Please sign in to comment.