Skip to content

Commit

Permalink
feat: Support custom repository and working-directory (#23)
Browse files Browse the repository at this point in the history
* 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 <dsanders11@ucsbalum.com>
  • Loading branch information
marcus-bcl and dsanders11 authored Aug 10, 2024
1 parent 5c7daab commit 43de6da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,21 @@ inputs:
message:
description: The commit message
required: true
owner:
description: The owner of the GitHub repo, defaults to the owner of the repository this action is running in
required: false
ref:
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.
required: false
repository:
description: The GitHub repository to commit to, defaults to the repository this action is running in
required: false
token:
description: The GitHub app installation token
required: true
working-directory:
description: The working directory, defaults to the current working directory
required: false

outputs:
message:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as process from 'node:process';

import * as core from '@actions/core';
import * as github from '@actions/github';
Expand Down Expand Up @@ -71,6 +72,13 @@ export async function run(): Promise<void> {
const ref = core.getInput('ref') || (await getHeadRef());
const failOnNoChanges = core.getBooleanInput('fail-on-no-changes');
const force = core.getBooleanInput('force');
const owner = core.getInput('owner') || github.context.repo.owner;
const repo = core.getInput('repository') || github.context.repo.repo;
const workingDirectory = core.getInput('working-directory');

if (workingDirectory) {
process.chdir(workingDirectory);
}

const tree = await populateTree();

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

const owner = github.context.repo.owner;
const repo = github.context.repo.repo;
const octokit = github.getOctokit(token, { log: console });

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

0 comments on commit 43de6da

Please sign in to comment.