-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: auto-merge translation PRs once approved
- Loading branch information
Showing
2 changed files
with
27 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,35 @@ | ||
import {adjustLabels} from '../api/ghLabels' | ||
import {parseArgs} from 'node:util' | ||
|
||
import {adjustLabels, PR_LABEL_APPROVED} from '../api/ghLabels' | ||
import {mergePR} from '../api/gitActions' | ||
import {runScript} from '../util/runScript' | ||
|
||
const PR_NUMBER = parseInt((process.env.PR_NUMBER || '').trim(), 10) | ||
if (!PR_NUMBER || PR_NUMBER <= 0 || isNaN(PR_NUMBER)) { | ||
throw new Error('PR_NUMBER environment variable is required') | ||
} | ||
|
||
runScript(() => | ||
adjustLabels({ | ||
const { | ||
values: {'merge-if-approved': mergeIfApproved}, | ||
} = parseArgs({ | ||
strict: true, | ||
options: { | ||
'merge-if-approved': { | ||
type: 'boolean', | ||
description: 'Merge the PR if it is approved by a maintainer', | ||
default: false, | ||
}, | ||
}, | ||
}) | ||
|
||
runScript(async () => { | ||
const result = await adjustLabels({ | ||
prNumber: PR_NUMBER, | ||
logger: (message) => console.log(message), | ||
}), | ||
) | ||
}) | ||
|
||
if (mergeIfApproved && result === PR_LABEL_APPROVED) { | ||
console.log('PR is approved, merging') | ||
await mergePR(PR_NUMBER) | ||
} | ||
}) |