From 3553522ff6fa96dacbb81a1aa4bf0d09e7c3a8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Fri, 16 Feb 2024 22:30:18 +0100 Subject: [PATCH] Expose file path as action output --- .github/workflows/main.yml | 22 +++++++++++++++++++++- action.yml | 3 +++ entrypoint.sh | 8 +++++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 55b93b1..56b5a24 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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' @@ -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 }} @@ -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' @@ -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: @@ -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 diff --git a/action.yml b/action.yml index 73516fa..d23d82c 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/entrypoint.sh b/entrypoint.sh index a013dc0..b745ec4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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"