forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (95 loc) · 3.26 KB
/
publish.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
name: Publish Build Artifacts
on: push
jobs:
publish_images:
# Optionally publish container images, guarded by the GitHub secret
# QUAY_PUBLISH.
# To set this up, sign up for quay.io (you can connect it to your github)
# then create a robot user with write access user called "bcc_buildbot",
# and add the secret token for it to GitHub secrets as:
# - QUAY_TOKEN = <token from quay.io>
name: Publish to quay.io
runs-on: ubuntu-latest
strategy:
matrix:
env:
- NAME: bionic-release
OS_RELEASE: 18.04
- NAME: focal-release
OS_RELEASE: 20.04
steps:
- uses: actions/checkout@v1
- name: Initialize workflow variables
id: vars
shell: bash
run: |
if [ -n "${QUAY_TOKEN}" ];then
echo "Quay token is set, will push an image"
echo ::set-output name=QUAY_PUBLISH::true
else
echo "Quay token not set, skipping"
fi
env:
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
- name: Authenticate with quay.io docker registry
if: >
steps.vars.outputs.QUAY_PUBLISH
env:
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
run: ./scripts/docker/auth.sh ${{ github.repository }}
- name: Package docker image and push to quay.io
if: >
steps.vars.outputs.QUAY_PUBLISH
run: >
./scripts/docker/push.sh
${{ github.repository }}
${{ github.ref }}
${{ github.sha }}
${{ matrix.env['NAME'] }}
${{ matrix.env['OS_RELEASE'] }}
# Uploads the packages built in docker to the github build as an artifact for convenience
- uses: actions/upload-artifact@v1
if: >
steps.vars.outputs.QUAY_PUBLISH
with:
name: ${{ matrix.env['NAME'] }}
path: output
# Optionally publish container images to custom docker repository,
# guarded by presence of all required github secrets.
# GitHub secrets can be configured as follows:
# - DOCKER_IMAGE = docker.io/myorg/bcc
# - DOCKER_USERNAME = username
# - DOCKER_PASSWORD = password
publish_dockerhub:
name: Publish To Dockerhub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Initialize workflow variables
id: vars
shell: bash
run: |
if [ -n "${DOCKER_IMAGE}" ] && \
[ -n "${DOCKER_USERNAME}" ] && \
[ -n "${DOCKER_PASSWORD}" ];then
echo "Custom docker credentials set, will push an image"
echo ::set-output name=DOCKER_PUBLISH::true
else
echo "Custom docker credentials not, skipping"
fi
env:
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Build container image and publish to registry
id: publish-registry
uses: elgohr/[email protected]
if: ${{ steps.vars.outputs.DOCKER_PUBLISH }}
with:
name: ${{ secrets.DOCKER_IMAGE }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
workdir: .
dockerfile: Dockerfile.ubuntu
snapshot: true
cache: ${{ github.event_name != 'schedule' }}