Skip to content

Commit

Permalink
Expose file path as action output
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Feb 16, 2024
1 parent edafd75 commit eac1f8a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ jobs:
issue-number: ${{ github.event.pull_request.number }}
body-includes: Test1

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

- uses: peter-evans/create-or-update-comment@v4
if: ${{ steps.dependency-diff.outputs.text-diff != null || steps.find_comment.outputs.comment-id != null }}
with:
Expand All @@ -55,6 +60,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 @@ -121,7 +128,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
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
8 changes: 5 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ 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

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 eac1f8a

Please sign in to comment.