Skip to content

Commit 9627ab4

Browse files
authored
Merge pull request #6 from mudlabs/dev
[dev] add old name
2 parents 5273c03 + 95fc361 commit 9627ab4

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ jobs:
2222
echo "Removed? ${{ steps.diff.outputs.removed }}"
2323
echo "Renamed? ${{ steps.diff.outputs.renamed }}"
2424
echo "Name: ${{ steps.diff.outputs.name }}"
25+
echo "Previous: ${{ steps.diff.outputs.previous }}"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Very simple, you provide the action with a `path` to a _file_ or _folder_, and i
3838
| `removed` | boolean | Specifies the file or folder was removed. |
3939
| `renamed` | boolean | Specifies the file or folder was renamed. |
4040
| `name` | string | Specifies the name of the file or folder. |
41+
| `previous` | string | Specifies the previous file name, or its name. |
4142

4243
## Example Case
4344
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)_.

action.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ const toBoolean = value => value.toLowerCase() == "true";
2727
if (response.data.status !== "ahead") throw `The head commit for this ${github.context.eventName} event is not ahead of the base commit.`;
2828

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

33+
core.setOutput("name", file ? file.filename : target);
3334
core.setOutput("added", file ? file.status === "added" : false);
34-
core.setOutput("modified", file ? file.status === "modified" : false);
3535
core.setOutput("removed", file ? file.status === "removed" : false);
3636
core.setOutput("renamed", file ? file.status === "renamed" : false);
37-
core.setOutput("name", file ? file.filename : target);
37+
core.setOutput("modified", file ? file.status === "modified" : false);
38+
core.setOutput("previous", file ? file.previous_filename || file.filename : target);
3839

3940
if (file) return;
4041
if (strict) throw `None of the files in this commits diff tree match the provided file (${path}).`;

action.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ outputs:
2929
description: Specifies the item was renamed.
3030
name:
3131
description: Specifies the item name.
32+
previous:
33+
description: The files previous name, or its name.

0 commit comments

Comments
 (0)