Skip to content

Commit

Permalink
update to fix for shortcut rename (#6)
Browse files Browse the repository at this point in the history
* update to fix for shortcut rename

* small changes
  • Loading branch information
zdxn authored Nov 19, 2021
1 parent 95c91fd commit 976ca1f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
![Test](https://github.com/farmersdog/clubhouse-pr/workflows/Test/badge.svg)

This action creates a formatted release in github from formatted commit messages annotated with clubhouse story data. [Clubhouse PR](https://github.com/marketplace/actions/clubhouse-pr)
This action creates a formatted release in github from formatted commit messages annotated with Shortcut story data. [Shortcut PR](https://github.com/marketplace/actions/clubhouse-pr)
can automatically format your PR titles (and commit messages, once merged) for use with this action.

## Inputs
Expand All @@ -21,7 +21,7 @@ Would you like to generate a changelog for this release?

### `chStoryUrl`

Clubhouse story URL (ie. https://app.clubhouse.io/org/story)
Shortcut story URL (ie. https://app.shortcut.com/org/story)

### `tag`

Expand Down Expand Up @@ -57,7 +57,7 @@ on:
uses: actions/release@v1
with:
ghToken: ${{ secrets.GITHUB_TOKEN }}
chStoryUrl: 'https://app.clubhouse.io/org/story'
chStoryUrl: 'https://app.shortcut.com/org/story'
tag: "v1.0.0"
## prerelease: false # default is true
previousTag: "v0.0.9" # is required if you're generating a changelog
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: 'Clubhouse Release'
name: 'Shortcut Release'
description: 'Create a formatted release in github from formatted commit messages'
inputs:
ghToken:
description: 'Github token'
required: true
chStoryUrl:
description: 'Clubhouse URL (ie. https://app.clubhouse.io/org/story)'
description: 'Shortcut URL (ie. https://app.shortcut.com/org/story)'
createChangelog:
description: 'Would you like to generate a changelog for this release?'
default: true
Expand Down
8 changes: 5 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function formatCommits(commits, chStoryUrl) {
const {
commit: { message },
} = com;
const regex = /(?<chType>\(\w*\))?(\s)?(?<prMsg>\w*\W*.+?)(\s+)?(\[)?(ch)?(?<chId>\d+)?(\])?\s\(#(?<prNumber>\d+)\)/;
const regex = /(?<chType>\(\w*\))?(\s)?(?<prMsg>\w*\W*.+?)(\s+)?(\[)?(sc-)?(?<chId>\d+)?(\])?\s\(#(?<prNumber>\d+)\)/;
const matches = message.match(regex);
const chType = formatChType(matches && matches.groups.chType);
const prMsg = (matches && matches.groups.prMsg) || message;
Expand All @@ -56,7 +56,7 @@ function formatCommits(commits, chStoryUrl) {
const chLink =
(matches &&
matches.groups.chId &&
`[ch${matches.groups.chId}](${chStoryUrl}/${matches.groups.chId})`) ||
`[sc-${matches.groups.chId}](${chStoryUrl}/${matches.groups.chId})`) ||
null;
const formattedCommit = { chLink, prMsg, prLink };

Expand Down Expand Up @@ -158,7 +158,9 @@ async function run() {
...github.context.repo,
name: tag,
tag_name: tag,
...(createChangelog && { body: changelog }),
...(createChangelog && {
body: `Service: ${github.context.repo}\n${changelog}`,
}),
prerelease: isPreRelease,
});
} catch (error) {
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function formatCommits(commits, chStoryUrl) {
const {
commit: { message },
} = com;
const regex = /(?<chType>\(\w*\))?(\s)?(?<prMsg>\w*\W*.+?)(\s+)?(\[)?(ch)?(?<chId>\d+)?(\])?\s\(#(?<prNumber>\d+)\)/;
const regex = /(?<chType>\(\w*\))?(\s)?(?<prMsg>\w*\W*.+?)(\s+)?(\[)?(sc-)?(?<chId>\d+)?(\])?\s\(#(?<prNumber>\d+)\)/;
const matches = message.match(regex);
const chType = formatChType(matches && matches.groups.chType);
const prMsg = (matches && matches.groups.prMsg) || message;
Expand All @@ -40,7 +40,7 @@ export function formatCommits(commits, chStoryUrl) {
const chLink =
(matches &&
matches.groups.chId &&
`[ch${matches.groups.chId}](${chStoryUrl}/${matches.groups.chId})`) ||
`[sc-${matches.groups.chId}](${chStoryUrl}/${matches.groups.chId})`) ||
null;
const formattedCommit = { chLink, prMsg, prLink };

Expand Down Expand Up @@ -142,7 +142,9 @@ export async function run() {
...github.context.repo,
name: tag,
tag_name: tag,
...(createChangelog && { body: changelog }),
...(createChangelog && {
body: `Service: ${github.context.repo}\n${changelog}`,
}),
prerelease: isPreRelease,
});
} catch (error) {
Expand Down
24 changes: 12 additions & 12 deletions testData.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
export const url = 'http://example.com/repo';
export const chStoryUrl = 'https://app.clubhouse.io/org/story';
export const chStoryUrl = 'https://app.shortcut.com/org/story';

export const fullCommits = [
{
commit: { message: '(feat) I am a feature [ch123] (#123)' },
commit: { message: '(feat) I am a feature [sc-123] (#123)' },
},
{
commit: { message: '(feature) I am a feature [ch000] (#000)' },
commit: { message: '(feature) I am a feature [sc-000] (#000)' },
},
{
commit: { message: '(bug) I am a bug fix [ch678] (#678)' },
commit: { message: '(bug) I am a bug fix [sc-678] (#678)' },
},
{
commit: { message: '(chore) I am a chore [ch345] (#345)' },
commit: { message: '(chore) I am a chore [sc-345] (#345)' },
},
];

Expand All @@ -37,26 +37,26 @@ export const prMsgOnlyCommits = [
export const formattedFullCommits = {
feature: [
{
chLink: `[ch123](${chStoryUrl}/123)`,
chLink: `[sc-123](${chStoryUrl}/123)`,
prMsg: 'I am a feature',
prLink: `[#123](${url}/pull/123)`,
},
{
chLink: `[ch000](${chStoryUrl}/000)`,
chLink: `[sc-000](${chStoryUrl}/000)`,
prMsg: 'I am a feature',
prLink: `[#000](${url}/pull/000)`,
},
],
bug: [
{
chLink: `[ch678](${chStoryUrl}/678)`,
chLink: `[sc-678](${chStoryUrl}/678)`,
prMsg: 'I am a bug fix',
prLink: `[#678](${url}/pull/678)`,
},
],
chore: [
{
chLink: `[ch345](${chStoryUrl}/345)`,
chLink: `[sc-345](${chStoryUrl}/345)`,
prMsg: 'I am a chore',
prLink: `[#345](${url}/pull/345)`,
},
Expand Down Expand Up @@ -94,21 +94,21 @@ export const changelogCommits = [
export const formattedChangelogCommits = {
feature: [
{
chLink: `[ch123](${chStoryUrl}/123)`,
chLink: `[sc-123](${chStoryUrl}/123)`,
prMsg: 'I am a feature',
prLink: `[#123](${url}/pull/123)`,
},
],
bug: [
{
chLink: `[ch678](${chStoryUrl}/678)`,
chLink: `[sc-678](${chStoryUrl}/678)`,
prMsg: 'I am a bug fix',
prLink: `[#678](${url}/pull/678)`,
},
],
chore: [
{
chLink: `[ch345](${chStoryUrl}/345)`,
chLink: `[sc-345](${chStoryUrl}/345)`,
prMsg: 'I am a chore',
prLink: `[#345](${url}/pull/345)`,
},
Expand Down

0 comments on commit 976ca1f

Please sign in to comment.