1
1
name : Build all and Check VirusTotal
2
2
3
- on : [push ]
3
+ on : [pull_request ]
4
4
5
5
jobs :
6
6
buildAll :
7
7
runs-on : ubuntu-latest
8
8
steps :
9
9
- uses : actions/checkout@v4
10
10
11
+ - name : Comment Building
12
+ uses : thollander/actions-comment-pull-request@v3
13
+ with :
14
+ message : |
15
+ :monkey: Monkeys are building your code...
16
+ comment-tag : pr_build_message
17
+ mode : upsert
18
+
11
19
- name : setup env
12
20
id : node-version
13
21
run : |
19
27
run : echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
20
28
21
29
- name : Cache yarn modules
22
- uses : actions/cache@v3
30
+ uses : actions/cache@v4
23
31
id : yarn-cache
24
32
with :
25
33
path : ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -35,21 +43,53 @@ jobs:
35
43
VIRUS_TOTAL_API_KEY : ${{secrets.VIRUS_TOTAL_API_KEY}}
36
44
GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
37
45
run : |
46
+ mkdir release-chrome
47
+ mkdir release-firefox
38
48
docker run --rm -v `pwd`:/home:rw --user "$(id -u):$(id -g)" enkrypt-build-container /bin/bash -c "yarn build:all"
39
49
docker run --rm -v `pwd`:/home:rw --user "$(id -u):$(id -g)" enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:chrome && yarn zip"
50
+ cp -r packages/extension/dist/* release-chrome
51
+ rm release-chrome/release.zip
40
52
FILE_SHA256=`sha256sum ./packages/extension/dist/release.zip | awk '{print $1}'`
41
53
curl --request GET --url https://www.virustotal.com/api/v3/files/upload_url --header "x-apikey: $VIRUS_TOTAL_API_KEY"
42
54
UPLOAD_URL=`curl --request GET --url https://www.virustotal.com/api/v3/files/upload_url --header "x-apikey: $VIRUS_TOTAL_API_KEY" | jq --raw-output '.data'`
43
55
curl --request POST --url "$UPLOAD_URL" --header "x-apikey: $VIRUS_TOTAL_API_KEY" --header 'Accept: application/json' --header 'Content-Type: multipart/form-data' -F "file=@./packages/extension/dist/release.zip"
44
56
VIRUS_TOTAL_URL_CHROME=https://www.virustotal.com/gui/file/$FILE_SHA256
45
57
docker run --rm -v `pwd`:/home:rw --user "$(id -u):$(id -g)" enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:firefox && yarn zip"
58
+ cp -r packages/extension/dist/* release-firefox
59
+ rm release-firefox/release.zip
46
60
FILE_SHA256=`sha256sum ./packages/extension/dist/release.zip | awk '{print $1}'`
47
61
curl --request GET --url https://www.virustotal.com/api/v3/files/upload_url --header "x-apikey: $VIRUS_TOTAL_API_KEY"
48
62
UPLOAD_URL=`curl --request GET --url https://www.virustotal.com/api/v3/files/upload_url --header "x-apikey: $VIRUS_TOTAL_API_KEY" | jq --raw-output '.data'`
49
63
curl --request POST --url "$UPLOAD_URL" --header "x-apikey: $VIRUS_TOTAL_API_KEY" --header 'Accept: application/json' --header 'Content-Type: multipart/form-data' -F "file=@./packages/extension/dist/release.zip"
50
64
VIRUS_TOTAL_URL_FIREFOX=https://www.virustotal.com/gui/file/$FILE_SHA256
51
- curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST \
52
- -d "{\"body\": \"Virus total analysis <br/>chrome: <br/>$VIRUS_TOTAL_URL_CHROME<br/> \
53
- firefox: <br/> \
54
- $VIRUS_TOTAL_URL_FIREFOX\"}" \
55
- "https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/comments"
65
+ echo "VIRUS_TOTAL_URL_CHROME=$VIRUS_TOTAL_URL_CHROME" >> $GITHUB_ENV
66
+ echo "VIRUS_TOTAL_URL_FIREFOX=$VIRUS_TOTAL_URL_FIREFOX" >> $GITHUB_ENV
67
+ echo "SHORT_SHA=`echo $(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha) | cut -c1-8`" >> $GITHUB_ENV
68
+
69
+ - uses : actions/upload-artifact@v4
70
+ id : artifact-upload-chrome
71
+ with :
72
+ name : enkrypt-chrome-${{ env.SHORT_SHA }}
73
+ path : ./release-chrome
74
+ retention-days : 3
75
+
76
+ - uses : actions/upload-artifact@v4
77
+ id : artifact-upload-firefox
78
+ with :
79
+ name : enkrypt-firefox-${{ env.SHORT_SHA }}
80
+ path : ./release-firefox
81
+ retention-days : 3
82
+
83
+ - name : Comment PR
84
+ uses : thollander/actions-comment-pull-request@v3
85
+ with :
86
+ message : |
87
+ :briefcase: Build Files
88
+ chrome: [enkrypt-chrome-${{ env.SHORT_SHA }}.zip](${{ steps.artifact-upload-chrome.outputs.artifact-url }})
89
+ firefox: [enkrypt-firefox-${{ env.SHORT_SHA }}.zip](${{ steps.artifact-upload-firefox.outputs.artifact-url }})
90
+
91
+ :syringe: Virus total analysis
92
+ chrome: [${{ env.SHORT_SHA }}](${{ env.VIRUS_TOTAL_URL_CHROME }})
93
+ firefox: [${{ env.SHORT_SHA }}](${{ env.VIRUS_TOTAL_URL_FIREFOX }})
94
+ comment-tag : pr_build_message
95
+ mode : upsert
0 commit comments