A super simple diff checker for your GitHub workflow.
Very simple, you provide the action with a path
to a file or folder, and it tells you if the file was added
, modified
, removed
, or renamed
. It will also output the items name
and previous
name, particularly usefull if it was just renamed
.
- name: Simple Diff
uses: mudlabs/[email protected]
with:
path: path/to/file
Input | Description | Default |
---|---|---|
path |
Specifies a path from the root of your repository to the file or folder you want to check. If not provided the action will try to find a path specification from the workflow file itself. The path can be a glob string. |
|
strict |
Specifies the action should fail if the path is not in the commits diff tree. |
true |
Output | Type | Description |
---|---|---|
added |
boolean | Specifies the file or folder was just added. |
modified |
boolean | Specifies the file or folder was modified. |
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. |
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).
- Note: In this example we do not specify the path property. If your workflow is conditioned to only run when changes to a given path occure, you don't need to provide the action with the file path. (assuming that's the file path you want to check).
name: My File Workflow
on:
push:
paths:
- path/to/my/file.ext
jobs:
diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Simple Diff
uses: mudlabs/[email protected]
id: diff
- run: exit 1
if: steps.diff.outputs.removed == true
# Other jobs will run only if file.ext was NOT removed.