Skip to content

Commit

Permalink
Merge pull request #6 from mudlabs/dev
Browse files Browse the repository at this point in the history
[dev] add old name
  • Loading branch information
mudlabs authored Oct 29, 2020
2 parents 5273c03 + 95fc361 commit 9627ab4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ jobs:
echo "Removed? ${{ steps.diff.outputs.removed }}"
echo "Renamed? ${{ steps.diff.outputs.renamed }}"
echo "Name: ${{ steps.diff.outputs.name }}"
echo "Previous: ${{ steps.diff.outputs.previous }}"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Very simple, you provide the action with a `path` to a _file_ or _folder_, and i
| `removed` | boolean | Specifies the file or folder was removed. |
| `renamed` | boolean | Specifies the file or folder was renamed. |
| `name` | string | Specifies the name of the file or folder. |
| `previous` | string | Specifies the previous file name, or its name. |

## Example Case
You have a workflow that only runs on a push event to a file path. But you don't want it to run if the file was `removed` _(deleted)_.
Expand Down
7 changes: 4 additions & 3 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ const toBoolean = value => value.toLowerCase() == "true";
if (response.data.status !== "ahead") throw `The head commit for this ${github.context.eventName} event is not ahead of the base commit.`;

const target = normalise(path);
const files = response.data.files;
const files = response.data.files;
const file = files.find(file => decodeURIComponent(file.contents_url).indexOf(`contents/${target}`) !== -1);

core.setOutput("name", file ? file.filename : target);
core.setOutput("added", file ? file.status === "added" : false);
core.setOutput("modified", file ? file.status === "modified" : false);
core.setOutput("removed", file ? file.status === "removed" : false);
core.setOutput("renamed", file ? file.status === "renamed" : false);
core.setOutput("name", file ? file.filename : target);
core.setOutput("modified", file ? file.status === "modified" : false);
core.setOutput("previous", file ? file.previous_filename || file.filename : target);

if (file) return;
if (strict) throw `None of the files in this commits diff tree match the provided file (${path}).`;
Expand Down
2 changes: 2 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ outputs:
description: Specifies the item was renamed.
name:
description: Specifies the item name.
previous:
description: The files previous name, or its name.

0 comments on commit 9627ab4

Please sign in to comment.