|
1 |
| -import * as core from '@actions/core' |
2 |
| -import * as github from '@actions/github' |
3 |
| - |
4 | 1 | import { execute } from "./src"
|
| 2 | +import { parseArgs } from 'bun' |
5 | 3 |
|
6 | 4 | export async function run(): Promise<void> {
|
7 | 5 | try {
|
8 | 6 | if (!process.env.GH_TOKEN) throw new Error('GH_TOKEN is not set')
|
9 | 7 |
|
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') |
11 | 23 |
|
12 | 24 | 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}`) |
18 | 30 |
|
19 |
| - const runtime = execute({ githubToken, logger: core }) |
| 31 | + const runtime = execute({ githubToken, logger: console }) |
20 | 32 | 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); |
23 | 35 | }
|
24 | 36 | }
|
25 | 37 |
|
|
0 commit comments