From 8780d2cb7f89bc2515c8eefa5649de50cbe2f2fa Mon Sep 17 00:00:00 2001 From: Jennifer Thakar Date: Fri, 7 Jul 2023 17:50:24 -0700 Subject: [PATCH] Fix diff link comment (#768) --- .github/workflows/shadow-repo-build.yml | 17 +++++++---- .github/workflows/shadow-repo-update.yml | 36 +++++++++++++++++++----- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/.github/workflows/shadow-repo-build.yml b/.github/workflows/shadow-repo-build.yml index 06412cf..5ad9719 100644 --- a/.github/workflows/shadow-repo-build.yml +++ b/.github/workflows/shadow-repo-build.yml @@ -28,13 +28,18 @@ jobs: name: site path: site.tar - diff-link: - name: Comment + prep-diff-link: + name: Prep comment runs-on: ubuntu-latest if: github.event_name == 'pull_request' && github.event.action == 'opened' steps: - - uses: peter-evans/create-or-update-comment@v3 - with: - issue-number: ${{ github.event.number }} - body: | + - name: Save comment + env: + COMMENT: | View diff of compiled files (may take a few minutes): https://github.com/${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }}/compare/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.ref }} + run: | + echo $COMMENT > ./comment.txt + - uses: actions/upload-artifact@v3 + with: + name: comment + path: comment.txt diff --git a/.github/workflows/shadow-repo-update.yml b/.github/workflows/shadow-repo-update.yml index e107d05..6dabc01 100644 --- a/.github/workflows/shadow-repo-update.yml +++ b/.github/workflows/shadow-repo-update.yml @@ -45,27 +45,49 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'workflow_run' steps: - - name: Clone shadow repo - uses: actions/checkout@v3 - with: - repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }} - token: ${{ secrets.SASS_SITE_TOKEN }} - ref: ${{ github.ref_name }} - path: shadow-repo - name: Download built site uses: dawidd6/action-download-artifact@v2.27.0 with: name: site run_id: ${{ github.event.workflow_run.id }} + if_no_artifact_found: ignore + - name: Clone shadow repo + uses: actions/checkout@v3 + if: steps.download_comment.outputs.found_artifact == 'true' + with: + repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }} + token: ${{ secrets.SASS_SITE_TOKEN }} + ref: ${{ github.ref_name }} + path: shadow-repo - name: Update shadow repo files + if: steps.download_comment.outputs.found_artifact == 'true' run: | rm -rf shadow_repo/* tar xf site.tar cp -rT _site shadow_repo - uses: EndBug/add-and-commit@v9 + if: steps.download_comment.outputs.found_artifact == 'true' with: cwd: shadow-repo author_name: Sass Bot author_email: sass.bot.beep.boop@gmail.com message: Update from https://github.com/${{ github.repository }}/commit/${{ github.sha }} commit: --allow-empty + + diff-link: + name: Comment + runs-on: ubuntu-latest + if: github.event_name == 'workflow_run' + steps: + - name: Download comment text + id: download_comment + uses: dawidd6/action-download-artifact@v2.27.0 + with: + name: comment + run_id: ${{ github.event.workflow_run.id }} + if_no_artifact_found: ignore + - uses: peter-evans/create-or-update-comment@v3 + if: steps.download_comment.outputs.found_artifact == 'true' + with: + issue-number: ${{ github.event.number }} + body_path: comment.txt