-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (62 loc) · 2.17 KB
/
Copy pathcommentLog.yml
File metadata and controls
66 lines (62 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Simple workflow for putting runner logs in Pull Request comments
name: LOG Runner Output As PR Comment
run-name: Commenting ${{ (inputs.failed_only == true && 'FAILED Run' || '') }} On ${{ inputs.branch_name }} Pull Request
on:
# Allows you to run this workflow manually from the Actions tab AND from other actions (fwTaskPushCreateCheck)
workflow_dispatch:
inputs:
run_id:
description: Run ID
required: true
repo_name:
description: Repository Name
required: true
branch_name:
description: Branch Name
required: true
failed_only:
description: "Only Failed Logs"
type: boolean
default: true
line_limit:
description: "Max Report Lines"
default: "50"
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pull-requests: write
jobs:
comment:
env:
ACTIONS_RUNNER_DEBUG: true
GH_TOKEN: ${{ github.token }}
runs-on: self-hosted
steps:
# Set Output After Delay For Trigger Workflow To Finish
- name: Sleep for 10 seconds
run: Start-Sleep -s 10
shell: powershell
# - name: Get Output
# id: log
# run: |
# echo "LOG=$( gh run view ${{ inputs.run_id }} --log ) >> $env:GITHUB_OUTPUT
# - name: Debug Log
# run: |
# echo ${{ steps.log.outputs.LOG || 'none'}}
# - name: Comment Pull Request With Log
# run: |
# gh pr comment --body "${{ toJSON(steps.log.outputs.LOG || 'none' ) }}"
- name: Log To File
if: ${{ !inputs.failed_only }}
run: |
gh run view ${{ inputs.run_id }} --log > output.log
- name: Log To File Failed Only
if: ${{ inputs.failed_only }}
run: |
gh run view ${{ inputs.run_id }} --log-failed > output.log
- name: Remove control characters
run: |
Get-Content output.log -Encoding UTF8 -Tail "${{ inputs.line_limit }}" | Set-Content outputUTF8.log
- name: Comment Pull Request With Log
run: |
gh pr comment -R ${{ inputs.repo_name }} ${{ inputs.branch_name }} --body-file outputUTF8.log