Skip to content

Commit

Permalink
Merge pull request #117 from usefulness/updates
Browse files Browse the repository at this point in the history
Expose file path as action output
  • Loading branch information
mateuszkwiecinski authored Feb 16, 2024
2 parents edafd75 + 635e521 commit caf66b6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ jobs:
project: ""
debug: true

- uses: actions/upload-artifact@v4
with:
name: file-diff-test-1
path: ${{ steps.dependency-diff.outputs.file-diff }}
if-no-files-found: error

- uses: peter-evans/find-comment@v3
id: find_comment
if: github.event_name == 'pull_request'
Expand All @@ -55,6 +61,8 @@ jobs:
```diff
${{ steps.dependency-diff.outputs.text-diff }}
```
file path: `${{ steps.dependency-diff.outputs.file-diff }}`
edit-mode: replace
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand Down Expand Up @@ -97,6 +105,12 @@ jobs:
additional-gradle-arguments: "--no-configuration-cache --stacktrace"
project: ""

- uses: actions/upload-artifact@v4
with:
name: file-diff-test-2
path: ${{ steps.dependency-diff.outputs.file-diff }}
if-no-files-found: error

- uses: peter-evans/find-comment@v3
id: find_comment
if: github.event_name == 'pull_request'
Expand All @@ -121,7 +135,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
os: [ windows-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
name: Execute on ${{ matrix.os }} runner
steps:
Expand Down Expand Up @@ -152,3 +166,10 @@ jobs:
project: ""
debug: true
additional-gradle-arguments: "--scan"

- uses: actions/upload-artifact@v4
if: matrix.os != 'windows-latest' # https://github.com/actions/upload-artifact/issues/337
with:
name: file-diff-test-on-${{ matrix.os }}
path: ${{ steps.dependency-diff.outputs.file-diff }}
if-no-files-found: error
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ outputs:
text-diff:
description: "Dependency diff"
value: ${{ steps.diff-generator.outputs.text-diff }}
file-diff:
description: "Path to a file containing the raw diff output"
value: ${{ steps.diff-generator.outputs.file-diff }}
branding:
color: 'red'
icon: 'check-square'
Expand Down
16 changes: 13 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,25 @@ fi

current_head=$(git rev-parse HEAD)

./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" >new_diff.txt
./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" > new_diff.txt
git fetch --force origin "$INPUT_BASEREF":"$INPUT_BASEREF" --no-tags
git switch --force "$INPUT_BASEREF"
./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" >old_diff.txt
java -jar dependency-tree-diff.jar old_diff.txt new_diff.txt >tree_diff.txt
./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" > old_diff.txt
java -jar dependency-tree-diff.jar old_diff.txt new_diff.txt > tree_diff.txt

if [ "$INPUT_DEBUG" == "true" ]; then
echo "diff generated"
ls -al
du tree_diff.txt
realpath tree_diff.txt
pwd
fi

delimiter=$(openssl rand -hex 20)
echo "text-diff<<$delimiter" >> $GITHUB_OUTPUT
cat tree_diff.txt >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT

echo "file-diff=$(realpath tree_diff.txt)" >> $GITHUB_OUTPUT

git switch --detach "$current_head"

0 comments on commit caf66b6

Please sign in to comment.