Skip to content

Commit

Permalink
Rename configuration option to WORKSPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalgn committed Jul 21, 2020
1 parent c908b8e commit efef88b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
tag_name: "v%s"
tag_message: "v%s"
commit_pattern: "^Release (\\S+)"
package_path: "."
workspace: "."
env: # More info about the environment variables in the README
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings
Expand All @@ -44,7 +44,7 @@ These inputs are optional: that means that if you don't enter them, default valu
- `tag_name`: the name pattern of the new tag
- `tag_message`: the message pattern of the new tag
- `commit_pattern`: pattern that the commit message needs to follow
- `package_path`: custom directory in the case that the package is not in the root.
- `workspace`: custom workspace directory that contains the `package.json` file

### Environment variables

Expand Down
19 changes: 5 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const { spawn } = require("child_process");
const { readFile } = require("fs");

async function main() {
const dir = getPackageDirectory();
const dir =
process.env.WORKSPACE ||
process.env.GITHUB_WORKSPACE ||
"/github/workspace";

const eventFile =
process.env.GITHUB_EVENT_PATH || "/github/workflow/event.json";
Expand Down Expand Up @@ -40,16 +43,6 @@ function getEnv(name) {
return process.env[name] || process.env[`INPUT_${name}`];
}

function getPackageDirectory() {
const workspace = process.env.GITHUB_WORKSPACE || "/github/workspace";
const packageLocation = join(workspace, placeholderEnv("PACKAGE_PATH", "."));
if(packageLocation.includes("package.json")){
return dirname(packageLocation);
}

return packageLocation;
}

function placeholderEnv(name, defaultValue) {
const str = getEnv(name);
if (!str) {
Expand Down Expand Up @@ -166,9 +159,7 @@ function run(cwd, command, ...args) {
if (code === 0) {
resolve(true);
} else {
const stderr = Buffer.concat(buffers)
.toString("utf8")
.trim();
const stderr = Buffer.concat(buffers).toString("utf8").trim();
if (stderr) {
console.log(`command failed with code ${code}`);
console.log(stderr);
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@
"rules": {
"no-console": "off"
}
},
"prettier": {
"trailingComma": "none",
"arrowParens": "avoid"
}
}

0 comments on commit efef88b

Please sign in to comment.