This is an action to compute a diff between head and base, and post it to a comment.
To post a comment of the diff between old-directory
and new-directory
,
- uses: int128/diff-action@v1
with:
base: old-directory
head: new-directory
If no difference, it post a comment of "No diff" by default.
If you use kustomize build
in your CI/CD pipeline, it would be useful if you can see the diff on a pull request.
To build manifests with int128/kustomize-action and show diff of it:
jobs:
diff:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write # required to post a comment to a pull request
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
ref: main
path: main
- uses: int128/kustomize-action@v1
id: kustomize-head
with:
kustomization: config/default/kustomization.yaml
write-individual-files: true
- uses: int128/kustomize-action@v1
id: kustomize-base
with:
base-directory: main
kustomization: config/default/kustomization.yaml
write-individual-files: true
- uses: int128/diff-action@v1
with:
base: ${{ steps.kustomize-base.outputs.directory }}
head: ${{ steps.kustomize-head.outputs.directory }}
Here is an example.
To add label(s) if there is difference or remove it if not:
- uses: int128/diff-action@v1
with:
base: ${{ steps.kustomize-base.outputs.directory }}
head: ${{ steps.kustomize-head.outputs.directory }}
label: manifest-changed
To change the comment of when no difference,
- uses: int128/diff-action@v1
with:
comment-body-no-diff: No diff of kustomize build
To suppress any comment when no difference,
- uses: int128/diff-action@v1
with:
comment-body-no-diff: ''
This action supports the following strategies:
create
: Create a new comment.replace
: Replace the body of existing comment if exists. (default)append
: Append the diff to the existing comment if exists.recreate
: Delete the existing comment and create a new one.
You can change the strategy by update-if-exists
.
This action identifies the existing comment by both workflow name and job name.
You can set a custom key to update-if-exists-key
.
This action posts a comment on pull_request
or pull_request_target
event only.
Name | Default | Description |
---|---|---|
base |
(required) | Path(s) of base (multiline) |
head |
(required) | Path(s) of head (multiline) |
label |
- | Label(s) to add or remove to indicate the diff (multiline) |
comment-body-no-diff |
No diff | Comment body when no difference |
comment-header |
- | Header of a comment to post |
comment-footer |
- | Footer of a comment to post |
update-if-exists |
(optional) | Either create , replace , append or recreate |
update-if-exists-key |
${{ github.workflow }}/${{ github.job }} |
Key for update-if-exists |
token |
github.token |
GitHub token to post a comment |
Name | Description |
---|---|
different |
If there is any difference, true . Otherwise, false |