Skip to content

Commit

Permalink
Add repository input (softprops#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
NAlexPear committed Oct 21, 2020
1 parent 4fb86a7 commit afb69be
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -181,6 +181,7 @@ The following are optional as `step.with` keys
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
| `name` | String | Name of the release. defaults to tag name |
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
| `repository` | String | Name of a target repository in `<owner>/<repo>` format. defaults to the current repository
| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing|

💡When providing a `body` and `body_path` at the same time, `body_path` will be attempted first, then falling back on `body` if the path can not be read from.
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Expand Up @@ -27,6 +27,9 @@ inputs:
fail_on_unmatched_files:
description: 'Fails if any of the `files` globs match nothing. Defaults to false'
required: false
repository:
description: 'Repository to make releases against, in <owner>/<repo> format'
required: false
env:
'GITHUB_TOKEN': 'As provided by Github Actions'
outputs:
Expand All @@ -37,4 +40,4 @@ runs:
main: 'dist/index.js'
branding:
color: 'green'
icon: 'package'
icon: 'package'
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/util.ts
@@ -1,5 +1,5 @@
import * as glob from "glob";
import { lstatSync, readFileSync } from "fs";
import {lstatSync, readFileSync} from "fs";

export interface Config {
github_token: string;
Expand All @@ -8,6 +8,7 @@ export interface Config {
// user provided
input_name?: string;
input_tag_name?: string;
input_repository?: string;
input_body?: string;
input_body_path?: string;
input_files?: string[];
Expand All @@ -24,7 +25,7 @@ export const releaseBody = (config: Config): string | undefined => {
);
};

type Env = { [key: string]: string | undefined };
type Env = {[key: string]: string | undefined};

export const parseInputFiles = (files: string): string[] => {
return files.split(/\r?\n/).reduce<string[]>(
Expand All @@ -41,7 +42,7 @@ export const parseConfig = (env: Env): Config => {
return {
github_token: env.GITHUB_TOKEN || "",
github_ref: env.GITHUB_REF || "",
github_repository: env.GITHUB_REPOSITORY || "",
github_repository: env.INPUT_REPOSITORY || env.GITHUB_REPOSITORY || "",
input_name: env.INPUT_NAME,
input_tag_name: env.INPUT_TAG_NAME,
input_body: env.INPUT_BODY,
Expand Down

0 comments on commit afb69be

Please sign in to comment.