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 3553522
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
22 changes: 21 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,9 @@ jobs:
project: ""
debug: true
additional-gradle-arguments: "--scan"

- uses: actions/upload-artifact@v4
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
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 3553522

Please sign in to comment.