Skip to content

Commit 43de6da

Browse files
feat: Support custom repository and working-directory (#23)
* feat: Support custom repository and working-directory Useful for when you have multiple repositories checked out * refactor: only change working directory is input provided * chore: update dist * chore: sort inputs by name --------- Co-authored-by: David Sanders <[email protected]>
1 parent 5c7daab commit 43de6da

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@ inputs:
1818
message:
1919
description: The commit message
2020
required: true
21+
owner:
22+
description: The owner of the GitHub repo, defaults to the owner of the repository this action is running in
23+
required: false
2124
ref:
2225
description: Git reference to associate the commit with (e.g. `main`). If it does not exist it will be created. Defaults to the the current checkout ref.
2326
required: false
27+
repository:
28+
description: The GitHub repository to commit to, defaults to the repository this action is running in
29+
required: false
2430
token:
2531
description: The GitHub app installation token
2632
required: true
33+
working-directory:
34+
description: The working directory, defaults to the current working directory
35+
required: false
2736

2837
outputs:
2938
message:

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from 'node:fs';
22
import * as path from 'node:path';
3+
import * as process from 'node:process';
34

45
import * as core from '@actions/core';
56
import * as github from '@actions/github';
@@ -71,6 +72,13 @@ export async function run(): Promise<void> {
7172
const ref = core.getInput('ref') || (await getHeadRef());
7273
const failOnNoChanges = core.getBooleanInput('fail-on-no-changes');
7374
const force = core.getBooleanInput('force');
75+
const owner = core.getInput('owner') || github.context.repo.owner;
76+
const repo = core.getInput('repository') || github.context.repo.repo;
77+
const workingDirectory = core.getInput('working-directory');
78+
79+
if (workingDirectory) {
80+
process.chdir(workingDirectory);
81+
}
7482

7583
const tree = await populateTree();
7684

@@ -83,8 +91,6 @@ export async function run(): Promise<void> {
8391
return;
8492
}
8593

86-
const owner = github.context.repo.owner;
87-
const repo = github.context.repo.repo;
8894
const octokit = github.getOctokit(token, { log: console });
8995

9096
// Upload file contents as blobs and update the tree with the returned SHAs

0 commit comments

Comments
 (0)