Skip to content

Commit 43f29d0

Browse files
authored
feat: ✨ allow 2 repo inputs: source and destination
1 parent edb8d47 commit 43f29d0

File tree

4 files changed

+50
-14
lines changed

4 files changed

+50
-14
lines changed

action.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ branding:
1010
# Define your inputs here.
1111
inputs:
1212
repo:
13-
description: 'The string represetation of the repo name (eg: lemlib/lemlib)'
13+
description: |
14+
Repository to which the depot will be pushed to.
15+
If source-repo is not defined, then this parameter will be assumed to be the source repo.
16+
If left undefined, then this parameter will be inferred from the workflow that called this action.
17+
example: "lemlib/lemlib"
18+
required: false
19+
20+
source-repo:
21+
description: |
22+
Repository from which to retrieve releases from
23+
If left undefined, then the repo parameter will be assumed to be the source repo.
24+
example: "lemlib/lemlib"
1425
required: false
1526

1627
token:

dist/index.js

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/licenses.txt

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import { updateDepots } from './update'
55

66
const repoInputRegex = /[^\/\n\s\t]+\/[^\/\n\s\t]+/
77

8-
function getRepositoryIdentifier(): RepositoryIdentifier {
8+
function getRepositoryIdentifier(repoInput: string): RepositoryIdentifier {
99
const repo: { owner: string; repo: string } = github.context.repo
10-
const repoInput = core.getInput('repo')
11-
12-
core.info('Repository input: ' + repoInput)
1310

1411
if (repoInput.match(repoInputRegex)) {
1512
const parsedRepoInput = repoInput.split('/')
@@ -18,6 +15,18 @@ function getRepositoryIdentifier(): RepositoryIdentifier {
1815
} else throw new Error('Invalid repository input: ' + repoInput)
1916
return repo
2017
}
18+
function getRepositoryIdentifiers(): Record<
19+
'srcRepo' | 'destRepo',
20+
RepositoryIdentifier
21+
> {
22+
const destInput = core.getInput('repo')
23+
let srcInput = core.getInput('source-repo')
24+
srcInput ??= destInput
25+
26+
const srcRepo = getRepositoryIdentifier(srcInput)
27+
const destRepo = getRepositoryIdentifier(destInput)
28+
return { srcRepo, destRepo }
29+
}
2130

2231
function getDepotLocations(): DepotRouteMap {
2332
const stableBranch = core.getInput('branch')
@@ -43,16 +52,15 @@ function getDepotLocations(): DepotRouteMap {
4352
*/
4453
export async function run(): Promise<void> {
4554
try {
46-
const repo = getRepositoryIdentifier()
55+
const repos = getRepositoryIdentifiers()
4756
const routes = getDepotLocations()
4857

4958
const readableFlag = core.getInput('readable') === 'true'
5059
const ghToken = core.getInput('token')
5160
const message = core.getInput('message')
5261

5362
updateDepots({
54-
destRepo: repo,
55-
srcRepo: repo,
63+
...repos,
5664
routes,
5765
readableJson: readableFlag,
5866
token: ghToken,

0 commit comments

Comments
 (0)