https://github.com/gr2m/watch-single-file-action-example
https://github.com/gr2m/watch-single-file-action-example
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gr2m/watch-single-file-action-example
- Owner: gr2m
- License: isc
- Created: 2020-02-28T17:34:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T04:34:06.000Z (almost 3 years ago)
- Last Synced: 2025-07-07T19:52:49.118Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 47.9 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# watch-single-file-action-example
> Example for a GitHub Action that acts on changes to a single file
## How it works
The workflow is defined in [`.github/workflows/watch-file.yaml`](.github/workflows/watch-file.yaml).
On every push event, [`index.js`](index.js) is run. The file that is being watched is passed as `FILE_PATH_TO_WATCH` environment variable. The [payload from the push event](https://developer.github.com/v3/activity/events/types/#pushevent) includes two properties: `"before"` and `"after"`, which ared use to find out which files have been changed using the [Compare two commits](https://developer.github.com/v3/repos/commits/#compare-two-commits) endpoint. If the changed files include the file that is being watched, the `"changed"` output for the step is set to `"true"`.
The next step can check for this output in order to act on the file change.
## LICENSE
[ISC](LICENSE)