GitHub Action
Git Delta Action
This GitHub Action helps you visualize and manage file changes (deltas) across different environments, branches, or commits. It uses the delta
tool to show diffs for specific files and folders, providing insights either offline or by querying GitHub via its REST API.
- Compare file changes (delta) between different Git branches, commits, or environments.
- Specify file patterns to include or exclude from the comparison.
- Run the delta check either offline or by querying the GitHub API.
Name | Description | Required | Default |
---|---|---|---|
github_token |
GitHub token for querying the GitHub REST API (used when comparing against environments). | No | N/A |
environment |
The environment to compare against (requires GitHub token if used). | No | N/A |
branch |
The base branch to compare against. | No | main |
commit |
Specific commit to compare against. | No | N/A |
includes |
Shell Glob style patterns to include in the delta calculation, separated by newlines (\n ). |
No | "" |
excludes |
Shell Glob style patterns to exclude from the delta calculation, separated by newlines (\n ). Excludes are applied after includes. |
No | "" |
online |
Whether to run the delta comparison online using the GitHub API (true ) or offline (false ). |
No | true |
includes: |
live/local/*
live/stag/ec2/terragrunt.hcl
excludes: |
*.zip
*/**/README.md
Name | Description |
---|---|
delta_files |
A JSON string with the paths of the files that have a delta (difference). |
is_detected |
A boolean value indicating whether a delta was detected or not. |
Here's an example of how to use this action in your workflow:
name: Check Git Delta
on: [push, pull_request]
jobs:
git-delta:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Run Git Delta
uses: jerry153fish/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: 'main'
includes: |
live/prod/*
live/stag/*
modules/*
excludes: |
**/*.md
In this example, the Git Delta action compares the current branch against the main
branch, considering only files in live/prod//
and live/prod//
while excluding markdown files (*.md
).
This action runs inside a Docker container. The latest version of the image used is:
docker://jerry153fish/git-delta:latest
To contribute to this project or make modifications:
- Fork the repository and clone it to your local machine.
- Make your changes or additions to the codebase.
- Test your changes thoroughly.
- Create a pull request with a clear description of your modifications.
For local development and testing:
- Ensure you have Docker and act installed on your machine.
- Create a
.secrets
file in the root directory of the project with the following content:
GITHUB_TOKEN=your_github_token
# Optional: only i you want to push the docker image
DOCKER_USER=your_docker_username
DOCKER_TOKEN=your_docker_password
- Run the following commands for help
make help
- Install dependencies
make install
- Lint
make fmt
make lint
- Tests
make test # Unit tests
make vet # Vet checks
make act-test # Runs `test` stage in the workflow of `.github/workflows/ci.yaml`
make act-sanity # Runs `sanity-check` stage in then workflow of `.github/workflows/ci.yaml`
- Build docker build
make act-docker # Run the whole workflow of `.github/workflows/ci.yaml`
This project is licensed under the MIT License - see the LICENSE file for details.