Skip to content

Commit 53317d9

Browse files
authored
Merge pull request #12 from Sy1v4in/fix/custom-action-definition-error
🐛 custom action definition error
2 parents b2a3caa + ba492d4 commit 53317d9

File tree

6 files changed

+33
-22
lines changed

6 files changed

+33
-22
lines changed

action.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ runs:
2323
steps:
2424
- uses: oven-sh/setup-bun@v1
2525
- uses: actions4git/setup-git@v1
26-
- run: bun ${{ github.action_path }}/index.ts
26+
- run: |
27+
bun ${{ github.action_path }}/index.ts
28+
--repository ${{ inputs.repository }}
29+
--source-branch ${{ inputs.source-branch }}
30+
--target-branch ${{ inputs.target-branch }}
31+
--label ${{ inputs.label }}
2732
shell: bash
28-
with:
29-
repository: ${{ inputs.repository }}
30-
source-branch: ${{ inputs.source-branch }}
31-
target-branch: ${{ inputs.target-branch }}
32-
label: ${{ inputs.label }}

bun.lockb

-740 Bytes
Binary file not shown.

index.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1-
import * as core from '@actions/core'
2-
import * as github from '@actions/github'
3-
41
import { execute } from "./src"
2+
import { parseArgs } from 'bun'
53

64
export async function run(): Promise<void> {
75
try {
86
if (!process.env.GH_TOKEN) throw new Error('GH_TOKEN is not set')
97

10-
core.info(JSON.stringify(github.context.payload, undefined, 2))
8+
const { values: inputs } = parseArgs({
9+
args: Bun.argv,
10+
options: {
11+
repository: { type: 'string' },
12+
'source-branch': { type: 'string' },
13+
'target-branch': { type: 'string' },
14+
label: { type: 'boolean' },
15+
},
16+
strict: true,
17+
allowPositionals: true,
18+
})
19+
if (!inputs['repository']) throw new Error('repository is required')
20+
if (!inputs['source-branch']) throw new Error('source-branch is required')
21+
if (!inputs['target-branch']) throw new Error('target-branch is required')
22+
if (!inputs['label']) throw new Error('label is required')
1123

1224
const githubToken = process.env.GH_TOKEN
13-
const repository: string[] = core.getInput('repository', { required: true }).split('/');
14-
const sourceBranch: string = core.getInput('source-branch', { required: true });
15-
const targetBranch: string = core.getInput('target-branch', { required: true });
16-
const label: string = core.getInput('label', { required: true });
17-
core.info(`Synchronizing branches and labels for repository ${repository.join('/')} from ${sourceBranch} to ${targetBranch} with label ${label}`)
25+
const repository: string[] = inputs.repository.split('/');
26+
const sourceBranch: string = inputs['source-branch']
27+
const targetBranch: string = inputs['target-branch']
28+
const label: string = inputs.label
29+
console.info(`Synchronizing branches and labels for repository ${repository.join('/')} from ${sourceBranch} to ${targetBranch} with label ${label}`)
1830

19-
const runtime = execute({ githubToken, logger: core })
31+
const runtime = execute({ githubToken, logger: console })
2032
await runtime.synchronizeBranchesAndLabels({ repository: { owner: repository[0], repo: repository[1] }, sourceBranch, targetBranch, label })
21-
} catch (error: any) {
22-
core.setFailed(error.message);
33+
} catch (error) {
34+
console.error(error);
2335
}
2436
}
2537

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"typescript": "^5.0.0"
1010
},
1111
"dependencies": {
12-
"@actions/core": "1.10.1",
1312
"@actions/github": "6.0.0",
1413
"@octokit/rest": "20.0.2"
1514
}

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ const execute = ({ githubToken, logger }: Context) => {
3838
}
3939

4040
if (branchesForWhichTheMergeHasFailed.length > 0) {
41-
logger.warning(`List of branches that have fail when merged on ${targetBranch}:`)
41+
logger.warn(`List of branches that have fail when merged on ${targetBranch}:`)
4242
branchesForWhichTheMergeHasFailed.forEach(branch => console.log(`\t• ${branch}`))
43-
logger.warning(`They have to be merged manually`)
43+
logger.warn(`They have to be merged manually`)
4444
}
4545

4646
if (branchNames.length > 0) {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export type Logger = {
22
debug: (message: string) => void
33
info: (message: string) => void
4-
warning: (message: string) => void
4+
warn: (message: string) => void
55
error: (message: string) => void
66
}
77

0 commit comments

Comments
 (0)