Skip to content

Commit 35556e4

Browse files
committed
ci/templates: properly propagate error
1 parent 6bc03f1 commit 35556e4

1 file changed

Lines changed: 28 additions & 36 deletions

File tree

.github/workflows/issue-linker.yml

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ jobs:
3232
with:
3333
script: |
3434
let issueNumber, issueData;
35-
35+
3636
if (context.eventName === 'workflow_dispatch') {
3737
issueNumber = '${{ inputs.issue_number }}';
38-
39-
38+
39+
4040
const response = await github.rest.issues.get({
4141
owner: context.repo.owner,
4242
repo: context.repo.repo,
@@ -47,7 +47,7 @@ jobs:
4747
issueData = context.payload.issue;
4848
issueNumber = issueData?.number;
4949
}
50-
50+
5151
const body = issueData.body || '';
5252
const childId = issueData.node_id;
5353
@@ -60,41 +60,33 @@ jobs:
6060
if (!parentMatch && !inputParentNumber) {
6161
throw new Error('No parent issue found in body and no parent_number input provided');
6262
}
63-
64-
const parentNumber = '${{ inputs.parent_number }}' || parseInt(parentMatch[1]);
63+
64+
const parentNumber = inputParentNumber || parseInt(parentMatch[1]);
6565
const owner = context.repo.owner;
6666
const repo = context.repo.repo;
67-
67+
6868
console.log(`Linking task #${issueNumber} to parent #${parentNumber}`);
69-
70-
try {
71-
const parentResponse = await github.rest.issues.get({
72-
owner,
73-
repo,
74-
issue_number: parentNumber
75-
});
76-
const parentNodeId = parentResponse.data.node_id;
77-
78-
const mutation = `
79-
mutation {
80-
addSubIssue(input: {
81-
issueId: "${parentNodeId}"
82-
subIssueId: "${childId}"
83-
}) {
84-
issue {
85-
number
86-
}
69+
70+
const parentResponse = await github.rest.issues.get({
71+
owner,
72+
repo,
73+
issue_number: parentNumber
74+
});
75+
const parentNodeId = parentResponse.data.node_id;
76+
77+
const mutation = `
78+
mutation {
79+
addSubIssue(input: {
80+
issueId: "${parentNodeId}"
81+
subIssueId: "${childId}"
82+
}) {
83+
issue {
84+
number
8785
}
8886
}
89-
`;
90-
91-
await github.graphql(mutation);
92-
93-
console.log(`Successfully linked #${issueNumber} as sub-issue of #${parentNumber}`);
94-
} catch (error) {
95-
console.error(`Error linking to parent: ${error.message}`);
96-
97-
if (error.status === 404) {
98-
console.error(`Parent issue #${parentNumber} not found`);
9987
}
100-
}
88+
`;
89+
90+
await github.graphql(mutation);
91+
92+
console.log(`Successfully linked #${issueNumber} as sub-issue of #${parentNumber}`);

0 commit comments

Comments
 (0)