diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index e79b959..8fe924b 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -18,23 +18,14 @@ jobs: - name: Run tapview if: success() || failure() - run: cat test-results.tap | ./.ci/tapview | tee test-results.txt - - - name: Collect tapview output - if: (success() || failure()) && github.event_name == 'pull_request' run: | - echo 'TEST_RESULTS<> $GITHUB_ENV - cat test-results.txt >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV + mkdir test-results + echo -n '${{ github.event.number }}' > test-results/PR + cat test-results.tap | ./.ci/tapview | tee test-results/test-results.txt - - uses: actions/github-script@v1 - if: (success() || failure()) && github.event_name == 'pull_request' + - name: Upload tapview results + uses: actions/upload-artifact@v3 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `${{ env.TEST_RESULTS }}` - }) + name: test-results + path: test-results/ + retention-days: 7 diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml new file mode 100644 index 0000000..fa2a2fb --- /dev/null +++ b/.github/workflows/comment.yml @@ -0,0 +1,42 @@ +name: Comment +on: + workflow_run: + workflows: + - Check + types: + - completed + +jobs: + + comment: + name: Comment on PR + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' + steps: + + - name: Download tapview results + uses: actions/download-artifact@v3 + with: + name: test-results + + - run: ls -lR + + - name: Collect results for comment + run: | + echo 'TEST_RESULTS<> $GITHUB_ENV + cat test-results.txt >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + echo "PR_NUMBER="$(cat PR)" >> $GITHUB_ENV + + - name: Post comment to PR + uses: actions/github-script@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.issues.createComment({ + issue_number: ${{ env.PR_NUMBER }}, + owner: context.repo.owner, + repo: context.repo.repo, + body: `${{ env.TEST_RESULTS }}` + })