Skip to content

Commit 28c0f8e

Browse files
committed
v2
1 parent aa18c18 commit 28c0f8e

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,3 @@ jobs:
4141
- name: Test
4242
id: npm-ci-test
4343
run: npm run ci-test
44-
45-
test-action:
46-
name: GitHub Actions Test
47-
runs-on: ubuntu-latest
48-
49-
steps:
50-
- name: Checkout
51-
id: checkout
52-
uses: actions/checkout@v4
53-
54-
- name: Test Local Action
55-
id: test-action
56-
uses: ./
57-
with:
58-
milliseconds: 2000
59-
60-
- name: Print Output
61-
id: output
62-
run: echo "${{ steps.test-action.outputs.time }}"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Linear release sync
22

3-
Add release label on linear tickets found in PRs merged in base branch since last release
4-
3+
Add release label on linear tickets found in PRs merged
4+
in base branch since last release
55

66
## Usage
77

@@ -13,4 +13,5 @@ Add release label on linear tickets found in PRs merged in base branch since las
1313
token: ${{ secrets.GITHUB_TOKEN }}
1414
linearApiKey: ${{ secrets.LINEAR_API_KEY }}
1515
releaseLabel: ${{ steps.bump-version.outputs.tag }}
16+
ticketPrefix: RAY
1617
```

action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
name: 'Linear release sync'
2-
description: 'Add release label on linear tickets found in PRs merged in base branch since last release'
2+
description: 'Add release on linear tickets in merged PRs since last release'
33
author: 'Rayon'
44

55

66
# Define your inputs here.
77
inputs:
88
token:
99
description: 'Github token'
10-
required: true
10+
required: false
11+
default: ${{ github.token }}
1112
linearApiKey:
1213
description: 'Linear API key'
1314
required: true
@@ -22,6 +23,10 @@ inputs:
2223
default: 'dev'
2324
required: false
2425
description: 'Main branch where PRs are merged'
26+
ticketPrefix:
27+
default: 'RAY'
28+
required: false
29+
description: 'Ticket prefix (can be a regex)'
2530

2631

2732

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export async function run(): Promise<void> {
66
try {
77
const token: string = core.getInput('token')
88
const apiKey: string = core.getInput('linearApiKey')
9+
const ticketPrefix: string = core.getInput('ticketPrefix')
910
const releaseLabelName: string = core.getInput('releaseLabel')
1011
const baseBranch = core.getInput('baseBranch')
1112
const maxPrLength = core.getInput('maxPrLength')
@@ -47,7 +48,9 @@ export async function run(): Promise<void> {
4748
const linearComment = comments.data.find(
4849
c => c.performed_via_github_app?.name === 'Linear'
4950
)
50-
const ticket = linearComment?.body?.match(/\bRAY-\d+\b/)
51+
const ticket = linearComment?.body?.match(
52+
new RegExp(`\b${ticketPrefix}-\d+\b`) // eslint-disable-line no-useless-escape
53+
)
5154
if (ticket) {
5255
console.log(`Found ticket ${ticket}`)
5356
}
@@ -73,12 +76,15 @@ export async function run(): Promise<void> {
7376
const releaseLabel = await (
7477
await linearClient.createIssueLabel({ name: releaseLabelName, parentId })
7578
).issueLabel
79+
if (!releaseLabel) {
80+
throw new Error('Cannot retrieve new version label')
81+
}
7682
for (const ref of linearTickets) {
7783
try {
7884
console.log(`Updating ticket ${ref}`)
7985
const ticket = await linearClient.issue(ref)
8086
await ticket.update({
81-
labelIds: [releaseLabel!.id, ...ticket.labelIds].filter(Boolean)
87+
labelIds: [releaseLabel.id, ...ticket.labelIds].filter(Boolean)
8288
})
8389
} catch (e) {
8490
console.error(e)

0 commit comments

Comments
 (0)