diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml index 3d044938a..9ea6468eb 100644 --- a/.github/workflows/uffizzi-build.yml +++ b/.github/workflows/uffizzi-build.yml @@ -101,7 +101,6 @@ jobs: run: | cat << EOF > event.json ${{ toJSON(github.event) }} - EOF - name: Upload PR Event as Artifact uses: actions/upload-artifact@v3 @@ -117,7 +116,10 @@ jobs: 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: echo '${{ toJSON(github.event) }}' > event.json + run: | + cat << EOF > event.json + ${{ toJSON(github.event) }} + EOF - name: Upload PR Event as Artifact uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/uffizzi-preview.yml b/.github/workflows/uffizzi-preview.yml index 5de1271f8..7ff238746 100644 --- a/.github/workflows/uffizzi-preview.yml +++ b/.github/workflows/uffizzi-preview.yml @@ -11,6 +11,7 @@ jobs: cache-compose-file: name: Cache Docker 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 }} @@ -28,6 +29,9 @@ jobs: let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { return artifact.name == "preview-spec" })[0]; + if (matchArtifact === undefined) { + throw TypeError('Build Artifact not found!'); + } let download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, repo: context.repo.repo, @@ -65,11 +69,13 @@ jobs: echo "PR number: ${{ env.PR_NUMBER }}" echo "Compose file hash: ${{ env.COMPOSE_FILE_HASH }}" cat event.json + deploy-uffizzi-preview: name: Run Uffizzi deployment needs: - cache-compose-file - uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2.6.1 + 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 # and this reusable workflow will delete the preview deployment.