|
13 | 13 | compile: |
14 | 14 | name: Compiles |
15 | 15 | runs-on: ubuntu-latest |
16 | | - defaults: |
17 | | - run: |
18 | | - shell: bash -e {0} 1>> ${{ github.workspace }}/stdout.log 2>> ${{ github.workspace }}/stderr.log |
19 | 16 | steps: |
20 | 17 | - uses: actions/checkout@v4 |
21 | 18 | with: |
@@ -56,22 +53,18 @@ jobs: |
56 | 53 | - name: post build errors as PR comment |
57 | 54 | if: failure() |
58 | 55 | run: | |
59 | | - # gh run view ${{ github.run_id }} --repo ${{ github.repository }} --log-failed > logs.txt |
60 | | - # ERRORS=$(cat logs.txt | |
61 | | - # cut -d$'\t' -f3 | # remove workflow/step columns |
62 | | - # cut -d' ' -f2-) # remove timestamp |
63 | | - # sed -n '/\[.*error.*\]/I,$p') # select lines from '[...error...]' or 'npm err' (case-insensitive) to EOF |
| 56 | + gh run view ${{ github.run_id }} --repo ${{ github.repository }} --log-failed > logs.txt |
64 | 57 |
|
65 | | - echo $SHELLOPTS |
| 58 | + ERRORS=$(cat logs.txt | |
| 59 | + cut -d$'\t' -f3 | # remove workflow/step columns |
| 60 | + cut -d' ' -f2-) # remove timestamp |
| 61 | + sed -n '/\[.*error.*\]/I,$p') # select lines from '[...error...]' or 'npm err' (case-insensitive) to EOF |
66 | 62 |
|
67 | | - ls ${{ github.workspace }} |
68 | | - cat ${{ github.workspace }}/stderr.log |
69 | | -
|
70 | | - if [ -s "stderr.log" ]; then |
| 63 | + if [ -n $ERRORS ]; then |
71 | 64 | echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token |
72 | 65 |
|
73 | 66 | URL=$(gh run view ${{ github.run_id }} --json url --jq '.url') |
74 | | - BODY="[Build failed]($URL)\n\n\`\`\`txt\n$(cat stderr.log)\n\`\`\`" |
| 67 | + BODY="[Build failed]($URL)\n\n\`\`\`txt\n$ERRORS\n\`\`\`" |
75 | 68 |
|
76 | 69 | gh pr comment ${{ github.event.number }} --repo ${{ github.repository }} --body $BODY |
77 | 70 | fi |
0 commit comments