diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index dbc263b..c002e65 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -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 }}"
diff --git a/README.md b/README.md
index c051344..4726946 100644
--- a/README.md
+++ b/README.md
@@ -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
@@ -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
```
diff --git a/action.yml b/action.yml
index 596e1c3..b19f420 100644
--- a/action.yml
+++ b/action.yml
@@ -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
@@ -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)'
diff --git a/badges/coverage.svg b/badges/coverage.svg
index b1372b6..8fd411f 100644
--- a/badges/coverage.svg
+++ b/badges/coverage.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/dist/index.js b/dist/index.js
index 6d77a6d..411c375 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -28953,7 +28953,10 @@ async function run() {
try {
const token = core.getInput('token');
const apiKey = core.getInput('linearApiKey');
+ const ticketPrefix = core.getInput('ticketPrefix');
const releaseLabelName = core.getInput('releaseLabel');
+ const baseBranch = core.getInput('baseBranch');
+ const maxPrLength = core.getInput('maxPrLength');
const linearClient = new sdk_1.LinearClient({ apiKey });
const octokit = github.getOctokit(token);
console.log('Getting Latest release...');
@@ -28964,11 +28967,11 @@ async function run() {
console.log('Getting pull requests...');
const pullRequests = await octokit.rest.pulls.list({
...github.context.repo,
- base: 'dev',
+ base: baseBranch,
state: 'closed',
sort: 'updated',
direction: 'desc',
- per_page: 100 // Adjust as needed
+ per_page: Number(maxPrLength)
});
const mergedPRs = pullRequests.data.filter(pr => pr.merged_at && pr.merged_at >= (latestRelease?.data?.published_at ?? 0));
console.log(`${mergedPRs.length} merged since last release`);
@@ -28979,7 +28982,8 @@ async function run() {
issue_number: Number(pr.number)
});
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}`);
}
@@ -28996,6 +29000,9 @@ async function run() {
}
console.log('Creating new version label...');
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}`);
diff --git a/src/main.ts b/src/main.ts
index 0b0f2f3..0f63eec 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -6,6 +6,7 @@ export async function run(): Promise {
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')
@@ -47,7 +48,9 @@ export async function run(): Promise {
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}`)
}
@@ -73,12 +76,15 @@ export async function run(): Promise {
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)