1+ name : CI Test
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - master
7+ - dev
8+ paths-ignore :
9+ - ' **.md'
10+
11+ jobs :
12+ image-test :
13+ name : Image Test
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v3
17+ - name : Lower case for ghcr
18+ id : ghcr_string
19+ uses : ASzc/change-string-case-action@v1
20+ with :
21+ string : ${{ github.event.repository.full_name }}
22+
23+ - name : Set up Docker Buildx
24+ uses : docker/setup-buildx-action@v1
25+
26+ - name : Cache Docker layers
27+ uses : actions/cache@v2
28+ with :
29+ path : /tmp/.buildx-cache
30+ key : ${{ runner.os }}-buildx-${{ github.sha }}
31+ restore-keys : |
32+ ${{ runner.os }}-buildx-
33+
34+ - name : Build image for testing
35+ uses : docker/build-push-action@v2
36+ with :
37+ context : .
38+ platforms : linux/amd64
39+ load : true
40+ tags : |
41+ ${{ steps.ghcr_string.outputs.lowercase }}
42+ cache-from : type=local,src=/tmp/.buildx-cache
43+ cache-to : type=local,dest=/tmp/.buildx-cache-new
44+
45+ - name : Move cache
46+ run : |
47+ rm -rf /tmp/.buildx-cache
48+ mv /tmp/.buildx-cache-new /tmp/.buildx-cache
49+
50+ - name : Install trivy
51+ run : |
52+ wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
53+ echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
54+ sudo apt-get update
55+ sudo apt-get install trivy -y
56+
57+ - name : Scan for CVEs
58+ uses : mathiasvr/command-output@v1
59+ id : trivy
60+ with :
61+ run : |
62+ trivy image --no-progress --severity "HIGH,CRITICAL" ${{ steps.ghcr_string.outputs.lowercase }}
63+
64+ - name : Comment CVE info on PR
65+ uses : thollander/actions-comment-pull-request@v1
66+ with :
67+ message : |
68+ ```
69+ ${{ steps.trivy.outputs.stdout }}
70+ ```
71+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments