-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (124 loc) · 4.44 KB
/
deliver-dockerhub.yaml
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
name: Deliver to DockerHub
on:
push:
pull_request:
release:
types: [published]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install cpplint
- name: Lint with cpplint
run: |
make lint
build:
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: get_version
name: Get version
run: |
echo "THEBLOCKCHAINKILLER_BUILD_VERSION=$(python get_app_version.py)" >> $GITHUB_OUTPUT
- name: Check version
run: |
echo THEBLOCKCHAINKILLER_BUILD_VERSION
echo ${{ steps.get_version.outputs.THEBLOCKCHAINKILLER_BUILD_VERSION }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build image
uses: docker/build-push-action@v3
with:
tags: kostaleonard/theblockchainkiller:latest,kostaleonard/theblockchainkiller:${{ steps.get_version.outputs.THEBLOCKCHAINKILLER_BUILD_VERSION }}
outputs: type=docker,dest=/tmp/theblockchainkiller.tar
cache-from: type=gha
cache-to: type=gha
- name: Upload Docker image artifact
uses: actions/upload-artifact@v2
with:
name: theblockchainkiller-image
path: /tmp/theblockchainkiller.tar
outputs:
THEBLOCKCHAINKILLER_BUILD_VERSION: ${{ steps.get_version.outputs.THEBLOCKCHAINKILLER_BUILD_VERSION }}
test:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download Docker image artifact
uses: actions/download-artifact@v2
with:
name: theblockchainkiller-image
path: .
- name: Load Docker image
run: |
docker load -i theblockchainkiller.tar
- name: Run tests
run: |
docker run -e THEBLOCKCHAINKILLER_TEST_PUBLIC_KEY=${{ secrets.THEBLOCKCHAINKILLER_TEST_PUBLIC_KEY }} -e THEBLOCKCHAINKILLER_TEST_PRIVATE_KEY=${{ secrets.THEBLOCKCHAINKILLER_TEST_PRIVATE_KEY }} --rm kostaleonard/theblockchainkiller:latest ./build/tests
valgrind:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download Docker image artifact
uses: actions/download-artifact@v2
with:
name: theblockchainkiller-image
path: .
- name: Load Docker image
run: |
docker load -i theblockchainkiller.tar
- name: Run valgrind on tests
run: |
docker run -e THEBLOCKCHAINKILLER_TEST_PUBLIC_KEY=${{ secrets.THEBLOCKCHAINKILLER_TEST_PUBLIC_KEY }} -e THEBLOCKCHAINKILLER_TEST_PRIVATE_KEY=${{ secrets.THEBLOCKCHAINKILLER_TEST_PRIVATE_KEY }} --rm kostaleonard/theblockchainkiller:latest valgrind --leak-check=full --error-exitcode=1 ./build/tests
trivy-scan:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download Docker image artifact
uses: actions/download-artifact@v2
with:
name: theblockchainkiller-image
path: .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
input: '/github/workspace/theblockchainkiller.tar'
format: 'table'
exit-code: '0'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
deliver:
needs: [lint, build, test, valgrind, trivy-scan]
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# These build steps use the cached images according to docker/build-push-action docs.
# We want to use the cached images so that we don't build twice.
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: kostaleonard/theblockchainkiller:latest,kostaleonard/theblockchainkiller:${{ needs.build.outputs.THEBLOCKCHAINKILLER_BUILD_VERSION }}
cache-from: type=gha
cache-to: type=gha