Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Cote-Boucher committed Nov 10, 2019
0 parents commit 35af51a
Show file tree
Hide file tree
Showing 473 changed files with 125,647 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## path-watcher-action

Given a comma-separated list of globs, returns whether the head commit that triggered the action involves a change in any of the input paths.

Usage:

```
on: [push]
jobs:
job:
runs-on: ubuntu-latest
steps:
- id: modified
uses: pheel/path-watcher-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # no need to set this secret, it is always available!
paths: 'dir1/**/*,dir2/**/*'
- if: steps.modified.outputs.modified
run: echo "Hey some change happened in one of your watched paths!"
```
17 changes: 17 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'path-watcher-action'
description: 'check whether the head commit involved a change in one of the input paths'
inputs:
github_token:
description: 'github token'
paths:
description: 'comma separated list of paths'
required: true
outputs:
modified:
description: 'whether the commit involves a change in any of the input paths'
branding:
icon: 'zoom-in'
color: 'purple'
runs:
using: 'node12'
main: 'index.js'
25 changes: 25 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const core = require('@actions/core');
const github = require('@actions/github');
const Octokit = require("@octokit/rest");
const minimatch = require('minimatch');

try {
const ghToken = core.getInput('github_token');
const octokit = new Octokit(ghToken ? { auth: ghToken } : {});
const paths = core.getInput('paths').split(',');
const commit_sha = github.context.payload.head_commit.id;
const [owner, repo] = github.context.payload.repository.full_name.split('/');
octokit.git.getCommit({ owner, repo, commit_sha })
.then(({ data: { files } }, err) => {
if (err) throw new Error(err);
if (Array.isArray(files)) {
const modifiedPaths = files.map(f => f.filename);
const modified = paths.some(p => minimatch.match(modifiedPaths, p).length);
core.setOutput('modified', modified);
} else {
core.setOutput('modified', false);
}
});
} catch (error) {
core.setFailed(error.message);
}
1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 140 additions & 0 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions node_modules/@actions/core/lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/@actions/core/lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 35af51a

Please sign in to comment.