Skip to content

Commit

Permalink
Merge pull request #19 from sendbird/fix/release-link
Browse files Browse the repository at this point in the history
fix: handle getLatestRelease not found error
  • Loading branch information
bang9 authored Sep 7, 2023
2 parents f2a0129 + 6d117b3 commit 42b674b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ inputs:
test:
required: false
description: 'Input actions run on testing environment'
default: 'false'
runs:
using: 'node16'
main: 'dist/index.js'
14 changes: 11 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "release-automation-action",
"version": "0.0.6",
"version": "0.0.7",
"private": true,
"description": "Sendbird Automate release process with GitHub Actions",
"license": "MIT",
Expand Down
23 changes: 14 additions & 9 deletions src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export const workflow = {
commandParams
)

if (ticketParams.test) this.log('Run on test environment')
if ('test' in ticketParams && ticketParams.test) {
this.log('Run on test environment')
}

const {repository, response} = await workflowRequest(
commandArgs,
Expand Down Expand Up @@ -98,13 +100,19 @@ export const workflow = {
async function buildCreateTicketParams(
args: CommandArguments,
params: CommandParameters
) {
): Promise<object> {
const basicParams = buildBasicRequestParams(WORKFLOWS.CREATE_TICKET)
const release_version = extractVersion(args.branch)

const latestRelease = await args.octokit.rest.repos.getLatestRelease(
github.context.repo
)
let latestReleaseLink = ''
try {
const latestRelease = await args.octokit.rest.repos.getLatestRelease(
github.context.repo
)
latestReleaseLink = latestRelease.data.html_url
} catch (e) {
latestReleaseLink = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/releases/tag/0.0.0`
}

return {
...basicParams,
Expand All @@ -113,10 +121,7 @@ async function buildCreateTicketParams(
product_jira_version_prefix: core.getInput('product_jira_version_prefix'),
release_branch: args.branch,
release_version,
release_gh_link: replaceVersion(
latestRelease.data.html_url,
release_version
),
release_gh_link: replaceVersion(latestReleaseLink, release_version),
release_pr_number: github.context.issue.number,
release_jira_version: buildReleaseJiraVersion(
basicParams.platform,
Expand Down

0 comments on commit 42b674b

Please sign in to comment.