From db89d41d194ca3487f509ec81b8c1b555531bfe5 Mon Sep 17 00:00:00 2001 From: Adam Vollrath Date: Mon, 30 Jan 2023 15:38:46 -0600 Subject: [PATCH] Uffizzi Preview Workflow Improvements * Add an explicit newline before the end of the event JSON blob. * Include conditions to skip without successful build workflow. * Upload event payload file directly from runner context. Signed-off-by: Adam Vollrath --- .github/workflows/uffizzi-build.yml | 14 ++------------ .github/workflows/uffizzi-preview.yaml | 4 +++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml index a23216a9cb..5c8e179958 100644 --- a/.github/workflows/uffizzi-build.yml +++ b/.github/workflows/uffizzi-build.yml @@ -89,16 +89,11 @@ jobs: name: preview-spec path: docker-compose.rendered.yml retention-days: 2 - - name: Serialize PR Event to File - run: | - cat << EOF > event.json - ${{ toJSON(github.event) }} - EOF - name: Upload PR Event as Artifact uses: actions/upload-artifact@v3 with: name: preview-spec - path: event.json + path: ${{ github.event_path }} retention-days: 2 delete-preview: @@ -107,14 +102,9 @@ jobs: if: ${{ github.event.action == 'closed' }} steps: # If this PR is closing, we will not render a compose file nor pass it to the next workflow. - - name: Serialize PR Event to File - run: | - cat << EOF > event.json - ${{ toJSON(github.event) }} - EOF - name: Upload PR Event as Artifact uses: actions/upload-artifact@v3 with: name: preview-spec - path: event.json + path: ${{ github.event_path }} retention-days: 2 diff --git a/.github/workflows/uffizzi-preview.yaml b/.github/workflows/uffizzi-preview.yaml index 3c344f5a78..6390671bbd 100644 --- a/.github/workflows/uffizzi-preview.yaml +++ b/.github/workflows/uffizzi-preview.yaml @@ -11,6 +11,7 @@ jobs: cache-compose-file: name: Cache Compose File runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} outputs: compose-file-cache-key: ${{ env.COMPOSE_FILE_HASH }} pr-number: ${{ env.PR_NUMBER }} @@ -47,7 +48,7 @@ jobs: run: | echo 'EVENT_JSON<> $GITHUB_ENV cat event.json >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV + echo -e '\nEOF' >> $GITHUB_ENV - name: Hash Rendered Compose File id: hash @@ -77,6 +78,7 @@ jobs: name: Use Remote Workflow to Preview on Uffizzi needs: - cache-compose-file + if: ${{ github.event.workflow_run.conclusion == 'success' }} uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2 with: # If this workflow was triggered by a PR close event, cache-key will be an empty string