-
Notifications
You must be signed in to change notification settings - Fork 3
136 lines (133 loc) · 4.85 KB
/
pull_requests_master.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: 'Pull requests: master'
on:
pull_request:
branches:
- master
jobs:
skip:
name: Check release skip
runs-on: ubuntu-latest
if: "! contains(github.event.pull_request.title, '[release skip]')"
steps:
- run: echo "${{ github.event.pull_request.title }}"
check_release_name:
name: Check release name
runs-on: ubuntu-latest
needs: [skip]
steps:
- uses: actions/checkout@master
- shell: bash
id: validate
run: |
VERSION='${{github.event.pull_request.title}}'
if [[ $VERSION =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
echo "::set-output name=version::${BASH_REMATCH[1]}"
else
exit 1
fi
- shell: bash
name: Make tag test.
run: |
git tag ${{steps.validate.outputs.version}}
git tag -d ${{steps.validate.outputs.version}}
- uses: thollander/actions-comment-pull-request@main
with:
message: |
**Merging this request will create release:**
Release name: Release ${{steps.validate.outputs.version}}
Tag: `${{steps.validate.outputs.version}}`
_Don't edit the merge commit message._
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: thollander/actions-comment-pull-request@main
with:
message: |
Failed. The possible causes are as:
1) Pull requests name is incorrect. Please include `[(\d+\.\d+\.\d+)]`.
2) Tag already exists.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: failure()
dockle:
name: Dockle scan
runs-on: ubuntu-latest
needs: [skip]
steps:
- uses: actions/checkout@master
- run: docker login --username ${{ secrets.DOCKER_HUB_USER }} --password ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build docker image
run: docker build ./ -t ${IMAGE_NAME} --file Dockerfile
- name: Install dockle
run: |
VERSION=$(curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | \
grep '"tag_name":' | \
sed -E 's/.*"v([^"]+)".*/\1/' \
)
curl -L -o dockle.deb /~https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.deb
sudo dpkg -i dockle.deb
rm dockle.deb
- name: Check image with dockle
# CIS-DI-0001: Create a user for the container
# DKL-DI-0006: Avoid latest tag
run: dockle --exit-code 1 --exit-level warn -i CIS-DI-0001 -i DKL-DI-0006 ${IMAGE_NAME}
- name: Slack Notification
uses: 8398a7/action-slack@v2
if: cancelled() || failure()
with:
status: ${{ job.status }}
author_name: ProjectPrimera/ongeki-score
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TEST }}
env:
IMAGE_NAME: projectprimera/ongeki-score
trivy:
name: Trivy scan
runs-on: ubuntu-latest
needs: [skip]
steps:
- uses: actions/checkout@master
- run: docker login --username ${{ secrets.DOCKER_HUB_USER }} --password ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build docker image
run: docker build ./ -t ${IMAGE_NAME} --file Dockerfile
- name: Install trivy
run: |
sudo apt-get install apt-transport-https gnupg
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -cs) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy
- name: Vulnerability scan with trivy
run: trivy -q image ${IMAGE_NAME}
# run: trivy -q --severity HIGH,CRITICAL --exit-code 1 ${IMAGE_NAME}
- name: Slack Notification
uses: 8398a7/action-slack@v2
if: cancelled() || failure()
with:
status: ${{ job.status }}
author_name: ProjectPrimera/ongeki-score
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TEST }}
env:
IMAGE_NAME: projectprimera/ongeki-score
slack:
name: Slack Notification
runs-on: ubuntu-latest
needs: [skip, check_release_name, dockle, trivy]
steps:
- name: Slack Notification
uses: 8398a7/action-slack@v2
if: always()
with:
status: ${{ job.status }}
author_name: ProjectPrimera/ongeki-score
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TEST }}
labeler:
name: Set label
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: ".github/labeler-master.yml"