forked from greenbone/openvas-scanner
-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (98 loc) · 3.67 KB
/
docker-ci.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
name: Build and upload docker images
on:
push:
branches: [ master, openvas-scanner-20.08, openvas-scanner-21.04, middleware ]
jobs:
upload-testing:
name: "Upload testing docker images"
runs-on: ubuntu-latest
strategy:
matrix:
compiler:
- gcc
- clang
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Find reference branch
run: |
echo $GITHUB_BASE_REF
echo $GITHUB_REF
if [ -n "$GITHUB_BASE_REF" ]; \
then echo "BRANCH=${GITHUB_BASE_REF##*/}" >> $GITHUB_ENV; \
else echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV; \
fi; \
- name: Find version
run: |
echo $BRANCH
if [ $BRANCH = "master" ]; \
then VERSION=master; \
else VERSION=$(echo "$BRANCH" | sed 's/openvas-scanner-//g' -); \
fi;
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# this only works with github.ref on push not on pull_request. ;)
- run: echo "Build and push ${{ github.repository }}-${{ env.VERSION }}-${{matrix.compiler}}-testing"
- name: Build and push
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ github.repository }}-${{ env.VERSION }}-${{matrix.compiler}}-testing
file: .docker/testing/Dockerfile
build-args: |
VERSION=${{ env.VERSION }}
COMPILER=${{matrix.compiler}}
upload-build:
needs: upload-testing
name: "Upload build docker images"
runs-on: ubuntu-latest
strategy:
matrix:
compiler:
- gcc
- clang
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Find reference branch
run: |
echo $GITHUB_BASE_REF
echo $GITHUB_REF
if [ -n "$GITHUB_BASE_REF" ]; \
then echo "BRANCH=${GITHUB_BASE_REF##*/}" >> $GITHUB_ENV; \
else echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV; \
fi; \
- name: Find version
run: |
echo $BRANCH
if [ $BRANCH = "master" ]; \
then VERSION=master; \
else VERSION=$(echo "$BRANCH" | sed 's/openvas-scanner-//g' -); \
fi;
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# this only works with github.ref on push not on pull_request. ;)
- run: echo "Build and push ${{ github.repository }}-${{ env.VERSION }}-${{matrix.compiler}}-build"
- name: Build and push
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ github.repository }}-${{ env.VERSION }}-${{matrix.compiler}}-build
file: .docker/build/Dockerfile
build-args: |
VERSION=${{ env.VERSION }}
COMPILER=${{matrix.compiler}}