Skip to content

Commit 290cc6a

Browse files
committed
feat: test on prod!!!
1 parent 985ae4d commit 290cc6a

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

action.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ inputs:
3333
version:
3434
description: 'Version'
3535
required: true
36-
environment:
37-
description: 'Environment'
38-
required: true
39-
project-name:
40-
description: 'Project name'
36+
project-id:
37+
description: 'Project Id'
4138
required: true
4239

4340
runs:

src/main.ts

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
import * as core from '@actions/core'
22
import PromisePool from '@supercharge/promise-pool'
33
import { Octokit } from 'octokit'
4-
import { array, parse, string } from 'valibot'
4+
import { array, InferOutput, object, parse, string } from 'valibot'
55

6-
const ReleaseTagsSchema = array(string())
6+
const ReleaseTags = array(string())
7+
8+
const ReleaseIssuesBody = object({
9+
projectId: string(),
10+
apps: array(
11+
object({
12+
appName: string(),
13+
issues: array(
14+
object({
15+
version: string(),
16+
issueId: string(),
17+
rawText: string()
18+
})
19+
)
20+
})
21+
)
22+
})
23+
type ReleaseIssuesBody = InferOutput<typeof ReleaseIssuesBody>
724

825
function parseReleaseTags(string: string) {
926
try {
10-
return parse(ReleaseTagsSchema, JSON.parse(string))
27+
return parse(ReleaseTags, JSON.parse(string))
1128
} catch (error) {
1229
core.setFailed(`Failed to parse releases-tags`)
1330
throw error
@@ -18,6 +35,7 @@ type ParsedIssue = {
1835
workspace: string
1936
issue: string
2037
title: string
38+
url: string
2139
}
2240

2341
export function parseIssueFromReleaseBody(
@@ -31,7 +49,10 @@ export function parseIssueFromReleaseBody(
3149
return matchedIssueUrls.map(url => {
3250
const IssueUrlPattern =
3351
/\(https:\/\/linear.app\/(?<workspace>\w+)\/issue\/(?<issue>.*)\/(?<title>.*)\)/g
34-
return IssueUrlPattern.exec(url)?.groups
52+
return {
53+
...IssueUrlPattern.exec(url)?.groups,
54+
url
55+
}
3556
}) as any
3657
}
3758

@@ -70,14 +91,34 @@ export async function releaseMode(): Promise<void> {
7091
return
7192
}
7293

73-
const issues = new Set<string>()
94+
const releaseIssues: ReleaseIssuesBody['apps'] = []
95+
7496
for (const {
75-
data: { body }
97+
data: { body, tag_name }
7698
} of results) {
7799
if (!body) continue
100+
// TODO: Add support for poly repos
101+
const version = tag_name.split('@').at(-1)!
102+
const appName = tag_name.split('@').slice(0, -1).join('@')
103+
const issues = new Set<string>()
104+
const issuesMap = new Map<string, ParsedIssue>()
105+
const app: ReleaseIssuesBody['apps'][0] = {
106+
appName,
107+
issues: []
108+
}
78109
for (const issue of parseIssueFromReleaseBody(body)) {
79110
issues.add(issue.issue)
111+
issuesMap.set(issue.issue, issue)
80112
}
113+
app.issues = Array.from(issues).map(issueId => {
114+
const { url } = issuesMap.get(issueId)!
115+
return {
116+
issueId,
117+
version,
118+
rawText: url
119+
}
120+
})
121+
releaseIssues.push(app)
81122
}
82123

83124
const releaseWebhookUrl = core.getInput('release-webhook-url')
@@ -89,12 +130,8 @@ export async function releaseMode(): Promise<void> {
89130
'Content-Type': 'application/json'
90131
},
91132
body: JSON.stringify({
92-
data: {
93-
version: core.getInput('version'),
94-
environment: core.getInput('environment'),
95-
projectName: core.getInput('project-name'),
96-
issues: Array.from(issues).map(issueId => ({ issueId }))
97-
}
133+
projectId: core.getInput('project-id'),
134+
apps: releaseIssues
98135
})
99136
})
100137

0 commit comments

Comments
 (0)