Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dkershner6/gitignore-parser
GitHub Action to parse a .gitignore file for information
https://github.com/dkershner6/gitignore-parser
github-actions nodejs
Last synced: 18 days ago
JSON representation
GitHub Action to parse a .gitignore file for information
- Host: GitHub
- URL: https://github.com/dkershner6/gitignore-parser
- Owner: dkershner6
- License: apache-2.0
- Created: 2020-05-30T00:48:47.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-28T00:09:03.000Z (6 months ago)
- Last Synced: 2024-05-28T09:37:45.211Z (6 months ago)
- Topics: github-actions, nodejs
- Language: TypeScript
- Homepage:
- Size: 1.03 MB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 29
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitIgnore Parser GitHub Action
GitHub Action to parse a .gitignore file for information. Generally, this is most useful when you are committing in your workflow, to ensure certain secret-containing files are not being committed.
This action uses the same .gitignore parser as eslint, prettier, and many others, and can be trusted for accuracy.
## Usage
### Inputs
| key | default | required | description |
|-----|---------|----------|-------------|
| path | `./` | false | The location of the .gitignore file from the repo root, with no filename. |
| must_deny | `''` | false | Comma-delimited string of files and paths the gitignore must deny being committed |
| must_accept | `''` | false | Comma-delimited string of files and paths the gitignore must accept being committed |
| fail_on_error | `'true'` | false | Boolean string ('true'/'false') to indicate whether the workflow should fail if a string in must_deny is not found |### Outputs
Will exist on `${{ steps.[id].outputs.[key] }}`
| key | description |
|-----|-------------|
| requirements_met | Returns a boolean string ('true'/'false') representing whether all of the lines in must_deny were indeed denied, and all must_accept were accepted |
| not_denied | A Comma-delimited string containing all of the lines from must_deny that were not denied |
| not_accepted | A Comma-delimited string containing all of the lines from must_accept that were not accepted |### Example Workflow
```yaml
on: pull_requestname: Run an action that commits
jobs:
build:
name: Create Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master- name: Ensure .npmrc and .env are .gitignored
id: gitignore-parser
uses: dkershner6/gitignore-parser@v2
with:
must_deny: '.npmrc,.env'
# Will fail if it doesn't deny either, but outputs are also present
- name: Print whether .gitignore denies .npmrc and .env
run: echo ${{ steps.gitignore-parser.outputs.requirements_met }}
```## Contributing
All contributions are welcome, please open an issue or pull request.
To use this repository:
1. `npm i -g pnpm` (if don't have pnpm installed)
2. `pnpm i`
3. `npx projen` (this will ensure everything is setup correctly, and you can run this command at any time)
4. Good to make your changes!
5. You can run `npx projen build` at any time to build the project.