Simple Github Action wrapper for Jake Wharton's Diffuse tool.
The action only exposes output containing the diff, so to effectively consume its output it is highly recommended to use other Github Actions to customize your experience.
The work
- id: diffuse
uses: usefulness/diffuse-action@v1
with:
old-file-path: old/file/path/old_file.apk
new-file-path: new/file/path/new_file.apk
lib-version: 0.1.0
old-file-path
- Path to reference file the diff should be generated for
new-file-path
- Path to current file the diff should be generated for
lib-version
(Optional) - Overrides Diffuse dependency version
fork-version
(Optional) - Uses Diffuse fork with a fiven version
TODO: explain why to use actions/cache for now and its limitation
- Integrate with a regular Pull Request workflow:
name: Pull Request workflow
on:
pull_request:
jobs:
generate-diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 16
- name: Build the apk
uses: gradle/gradle-build-action@v1
with:
arguments: assembleDebug
dependencies-cache-enabled: true
# Generating the diff starts here 👇
- uses: actions/cache@v2
name: Download base
with:
path: diffuse-source-file
key: diffuse-${{ github.event.pull_request.base.sha }}
- id: diffuse
uses: usefulness/diffuse-action@v1
with:
old-file-path: diffuse-source-file
new-file-path: app/build/outputs/release/app.apk
# Consuming action output starts here 👇
- uses: peter-evans/find-comment@v1
id: find_comment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: Diffuse output
- uses: peter-evans/create-or-update-comment@v1
if: ${{ steps.diffuse.outputs.diff-raw != null || steps.find_comment.outputs.comment-id != null }}
with:
body: |
Diffuse output (customize your message here):
${{ steps.diffuse.outputs.diff-gh-comment }}
edit-mode: replace
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v2
with:
name: diffuse-output
path: ${{ steps.diffuse.outputs.diff-file }}
- Integrate with you post-merge flow:
on:
push:
branches:
- master
- main
- trunk
- develop
- maine
- mane
jobs:
diffuse_cache:
runs-on: ubuntu-latest
name: Cache artifact for diffuse
steps:
- uses: actions/checkout@v2
- name: set up JDK
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 16
- name: Build the app
uses: gradle/gradle-build-action@v1
with:
arguments: assembleDebug
dependencies-cache-enabled: true
# Integration starts here 👇
- uses: actions/cache@v2
name: Upload base
with:
path: diffuse-source-file
key: diffuse-${{ github.sha }}
# Copy your build artifact under `diffuse-source-file` name which will be saved in cache
- run: cp sample-apk.apk diffuse-source-file
shell: bash
Sample application as a pull request comment
Corresponding workflow file
🙏 Praise 🙏 be 🙏 to 🙏 Wharton 🙏