diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index adca5601a..3fe9d2bf9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -136,18 +136,21 @@ jobs: name: db.head.json.gz path: head - name: Diff databases - run: packages/@aws-cdk/service-spec-importers/bin/diff-db base/db.json.gz head/db.json.gz > DIFF - - id: diff-db + id: diff-db + run: packages/@aws-cdk/service-spec-importers/bin/diff-db base/db.json.gz head/db.json.gz > DIFF || echo "diff-result=true" >> $GITHUB_OUTPUT + continue-on-error: true + - name: Create PR.md + if: steps.diff-db.outputs.diff-result run: |- - echo "diff=$(cat DIFF)" >> $GITHUB_OUTPUT - echo "\`\`\`\n$(cat DIFF)\n\`\`\`\" >> $GITHUB_STEP_SUMMARY + echo 'Model database diff introduced between base and head branch: + + ' >> PR.md + echo '```\n' >> PR.md + cat DIFF >> PR.md + echo '\n```\n' >> PR.md - name: Comment diff - if: ${{ steps.diff-db.outputs.diff }} + if: steps.diff-db.outputs.diff-result uses: thollander/actions-comment-pull-request@v2 with: comment_tag: diff-db - message: | - Model database diff introduced between base and head branch: - ``` - ${{ steps.diff-db.outputs.diff }} - ``` + filePath: PR.md diff --git a/projenrc/diff-db.ts b/projenrc/diff-db.ts index 6cfd4b8c8..918c6b11d 100644 --- a/projenrc/diff-db.ts +++ b/projenrc/diff-db.ts @@ -126,24 +126,30 @@ export class DiffDb extends pj.Component { }, { name: 'Diff databases', - run: `${this.path(this.importers.outdir + '/bin/diff-db')} base/db.json.gz head/db.json.gz > DIFF`, + id: 'diff-db', + continueOnError: true, + run: `${this.path( + this.importers.outdir + '/bin/diff-db', + )} base/db.json.gz head/db.json.gz > DIFF || echo "diff-result=true" >> $GITHUB_OUTPUT`, }, { - id: 'diff-db', + name: 'Create PR.md', + if: 'steps.diff-db.outputs.diff-result', run: [ - 'echo "diff=$(cat DIFF)" >> $GITHUB_OUTPUT', - 'echo "\\`\\`\\`\\n$(cat DIFF)\\n\\`\\`\\`\\" >> $GITHUB_STEP_SUMMARY', + "echo 'Model database diff introduced between base and head branch:\n\n' >> PR.md", + "echo '```\\n' >> PR.md", + 'cat DIFF >> PR.md', + "echo '\\n```\\n' >> PR.md", + // 'echo "(cat PR.md)" >> $GITHUB_STEP_SUMMARY', ].join('\n'), }, - { name: 'Comment diff', - if: '${{ steps.diff-db.outputs.diff }}', + if: 'steps.diff-db.outputs.diff-result', uses: 'thollander/actions-comment-pull-request@v2', with: { comment_tag: 'diff-db', - message: - 'Model database diff introduced between base and head branch:\n```\n${{ steps.diff-db.outputs.diff }}\n```\n', + filePath: 'PR.md', }, }, ],