Skip to content
Merged

v2 #5

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,3 @@ jobs:
- name: Test
id: npm-ci-test
run: npm run ci-test

test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: test-action
uses: ./
with:
milliseconds: 2000

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Linear release sync

Add release label on linear tickets found in PRs merged in base branch since last release

Add release label on linear tickets found in PRs merged
in base branch since last release

## Usage

Expand All @@ -13,4 +13,5 @@ Add release label on linear tickets found in PRs merged in base branch since las
token: ${{ secrets.GITHUB_TOKEN }}
linearApiKey: ${{ secrets.LINEAR_API_KEY }}
releaseLabel: ${{ steps.bump-version.outputs.tag }}
ticketPrefix: RAY
```
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: 'Linear release sync'
description: 'Add release label on linear tickets found in PRs merged in base branch since last release'
description: 'Add release on linear tickets in merged PRs since last release'
author: 'Rayon'


# Define your inputs here.
inputs:
token:
description: 'Github token'
required: true
required: false
default: ${{ github.token }}
linearApiKey:
description: 'Linear API key'
required: true
Expand All @@ -22,6 +22,10 @@ inputs:
default: 'dev'
required: false
description: 'Main branch where PRs are merged'
ticketPrefix:
default: 'RAY'
required: false
description: 'Ticket prefix (can be a regex)'



Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions dist/index.js

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

10 changes: 8 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export async function run(): Promise<void> {
try {
const token: string = core.getInput('token')
const apiKey: string = core.getInput('linearApiKey')
const ticketPrefix: string = core.getInput('ticketPrefix')
const releaseLabelName: string = core.getInput('releaseLabel')
const baseBranch = core.getInput('baseBranch')
const maxPrLength = core.getInput('maxPrLength')
Expand Down Expand Up @@ -47,7 +48,9 @@ export async function run(): Promise<void> {
const linearComment = comments.data.find(
c => c.performed_via_github_app?.name === 'Linear'
)
const ticket = linearComment?.body?.match(/\bRAY-\d+\b/)
const ticket = linearComment?.body?.match(
new RegExp(`\b${ticketPrefix}-\d+\b`) // eslint-disable-line no-useless-escape
)
if (ticket) {
console.log(`Found ticket ${ticket}`)
}
Expand All @@ -73,12 +76,15 @@ export async function run(): Promise<void> {
const releaseLabel = await (
await linearClient.createIssueLabel({ name: releaseLabelName, parentId })
).issueLabel
if (!releaseLabel) {
throw new Error('Cannot retrieve new version label')
}
for (const ref of linearTickets) {
try {
console.log(`Updating ticket ${ref}`)
const ticket = await linearClient.issue(ref)
await ticket.update({
labelIds: [releaseLabel!.id, ...ticket.labelIds].filter(Boolean)
labelIds: [releaseLabel.id, ...ticket.labelIds].filter(Boolean)
})
} catch (e) {
console.error(e)
Expand Down