@@ -5,54 +5,101 @@ name: "Size: Comment"
5
5
#
6
6
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
7
7
on :
8
+ workflow_dispatch :
9
+ inputs :
10
+ RUN_ID :
11
+ description : Which workflow run to get artifacts from
12
+ required : true
13
+ type : string
8
14
workflow_run :
9
15
workflows : ["Size: PR"]
10
16
types :
11
17
- completed
12
18
19
+ permissions :
20
+ contents : read
21
+ issues : write
22
+ pull-requests : write
23
+
13
24
jobs :
14
25
compare_sizes :
15
26
name : ' Compare Sizes and Comment'
16
27
runs-on : ' ubuntu-latest'
17
28
18
29
steps :
30
+ # better `du`
19
31
- run : sudo snap install dust
20
32
21
- - uses : actions/ download-artifact@v4
33
+ - uses : dawidd6/action- download-artifact@v9
22
34
with :
23
- name : pr-${{ github.event.workflow_run.id }}
35
+ run_id : ${{ inputs.RUN_ID || github.event.workflow_run.id }}
36
+ workflow : size-pr.yml
37
+ path : pr
38
+ if_no_artifact_found : fail
24
39
25
- - uses : actions/ download-artifact@v4
40
+ - uses : dawidd6/action- download-artifact@v9
26
41
with :
27
42
name : sizes-main
43
+ path : main
44
+ workflow : size-main.yml
45
+ if_no_artifact_found : fail
28
46
29
- - name : " [PR] Get sizes for development outputs"
30
- id : dev
47
+ - name : " [Debug] artifacts' files"
48
+ run : |
49
+ ls -la ./main
50
+ ls -la ./pr/**
51
+
52
+ - name : " [PR] Get path of size output txt file"
53
+ id : find-pr-txt
31
54
run : |
32
55
cd pr/
56
+ filePath=$(find . -name "out.txt")
57
+ echo $filePath
58
+ echo "txtPath=pr/$filePath" >> $GITHUB_OUTPUT
33
59
60
+ - name : " [PR] Get PR number"
61
+ id : find-pr-number
62
+ run : |
63
+ cd pr/
64
+ filePath=$(find . -name "NR")
65
+ contents=$(cat $filePath)
66
+ echo $filePath
67
+ echo $contents
68
+ echo "prNumber=$contents" >> $GITHUB_OUTPUT
69
+
70
+ - name : " [PR] Get sizes for development outputs"
71
+ id : dev
72
+ run : |
73
+ cat ${{ steps.find-pr-txt.outputs.txtPath }}
34
74
echo 'sizes<<EOF' >> $GITHUB_OUTPUT
35
75
while IFS= read -r line; do
36
76
echo "$line" >> $GITHUB_OUTPUT
37
- done <<< $(cat out. txt)
77
+ done <<< $(cat ${{ steps.find-pr- txt.outputs.txtPath }} )
38
78
echo 'EOF' >> $GITHUB_OUTPUT
39
- cat out.txt
40
-
41
- - name : " [PR]: Get PR Number"
42
- id : pr-number
43
- run : echo "number=$(cat pr/NR)" >> $GITHUB_OUTPUT
44
79
45
80
- name : " [Main] Get sizes for development outputs"
46
81
id : main-dev
47
82
run : |
48
83
cd main/
84
+ cat out.txt
49
85
50
86
echo 'sizes<<EOF' >> $GITHUB_OUTPUT
51
87
while IFS= read -r line; do
52
88
echo "$line" >> $GITHUB_OUTPUT
53
89
done <<< $(cat out.txt)
54
90
echo 'EOF' >> $GITHUB_OUTPUT
55
- cat out.txt
91
+
92
+
93
+ - name : " [Debug] collected data from artifacts"
94
+ run : |
95
+ echo "PR number"
96
+ echo -e "${{ steps.find-pr-number.outputs.prNumber }}"
97
+
98
+ echo "Main out.txt"
99
+ echo -e "${{ steps.main-dev.outputs.sizes }}"
100
+
101
+ echo "PR out.txt"
102
+ echo -e "${{ steps.dev.outputs.sizes }}"
56
103
57
104
# ########################
58
105
# Intended Layout:
68
115
# ########################
69
116
- uses : mshick/add-pr-comment@v2
70
117
with :
71
- issue : ${{ steps.pr-number.outputs.number }}
118
+ issue : ${{ steps.find- pr-number.outputs.prNumber }}
72
119
message : |
73
120
<table><thead><tr><th></th><th>This PR</th><th>main</th></tr></thead>
74
121
<tbody>
0 commit comments