Skip to content

Commit 0783d48

Browse files
authored
chore(build): add support to push to multiple registries (#11)
- add support to push images to multiple registries - use ubuntu-latest in the workflow - use docker build-push action instead of scripts - update alpine version to 3.12.4 to mitigate some vulnerabilities marked as HIGH severity Signed-off-by: Akhil Mohan <[email protected]>
1 parent a5b5a02 commit 0783d48

File tree

4 files changed

+110
-19
lines changed

4 files changed

+110
-19
lines changed

.github/workflows/build.yml

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,42 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v2
2424

25-
- name: Set tag
25+
- name: Set Image Org
26+
# sets the default IMAGE_ORG to openebs
27+
run: |
28+
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
29+
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
30+
31+
- name: Set CI Tag
2632
run: |
2733
BRANCH="${GITHUB_REF##*/}"
2834
CI_TAG=${BRANCH#v}-ci
2935
if [ ${BRANCH} = "master" ]; then
3036
CI_TAG="ci"
3137
fi
3238
echo "TAG=${CI_TAG}" >> $GITHUB_ENV
33-
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
39+
40+
- name: Set Build Date
41+
id: date
42+
run: |
43+
echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')"
44+
45+
- name: Docker meta
46+
id: docker_meta
47+
uses: crazy-max/ghaction-docker-meta@v1
48+
with:
49+
# add each registry to which the image needs to be pushed here
50+
images: |
51+
${{ env.IMAGE_ORG }}/linux-utils
52+
quay.io/${{ env.IMAGE_ORG }}/linux-utils
53+
tag-latest: false
54+
tag-custom-only: true
55+
tag-custom: |
56+
${{ env.TAG }}
57+
58+
- name: Print Tags
59+
run: |
60+
echo "${{ steps.docker_meta.outputs.tags }}"
3461
3562
- name: Setup QEMU
3663
uses: docker/setup-qemu-action@v1
@@ -49,13 +76,28 @@ jobs:
4976
username: ${{ secrets.DOCKERHUB_USERNAME }}
5077
password: ${{ secrets.DOCKERHUB_TOKEN }}
5178

79+
- name: Login to Quay
80+
uses: docker/login-action@v1
81+
with:
82+
registry: quay.io
83+
username: ${{ secrets.QUAY_USERNAME }}
84+
password: ${{ secrets.QUAY_TOKEN }}
85+
5286
- name: Build & Push Image
53-
run: |
54-
make buildx.image
55-
make buildx.push
87+
uses: docker/build-push-action@v2
88+
with:
89+
file: ./Dockerfile
90+
push: true
91+
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
92+
tags: |
93+
${{ steps.docker_meta.outputs.tags }}
94+
build-args: |
95+
DBUILD_DATE=${{ steps.date.outputs.DATE }}
96+
DBUILD_REPO_URL=https://github.com/openebs/linux-utils
97+
DBUILD_SITE_URL=https://openebs.io
5698
5799
trivy:
58-
runs-on: ubuntu-18.04
100+
runs-on: ubuntu-latest
59101
needs: ['linux-utils']
60102
steps:
61103
- name: Checkout code
@@ -64,7 +106,9 @@ jobs:
64106
- name: Run Trivy vulnerability scanner
65107
uses: aquasecurity/trivy-action@master
66108
with:
67-
image-ref: openebs/linux-utils:${{ env.TAG }}
109+
# the tag will be always ci since only master branch is present
110+
# in this repository
111+
image-ref: 'openebs/linux-utils:ci'
68112
format: 'table'
69113
exit-code: '1'
70114
ignore-unfixed: true

.github/workflows/pull_request.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ jobs:
4040
version: v0.5.1
4141

4242
- name: Build Image
43-
env:
44-
IMG_RESULT: load
45-
run: make buildx.image
43+
uses: docker/build-push-action@v2
44+
with:
45+
file: ./Dockerfile
46+
push: false
47+
load: true
48+
platforms: linux/amd64
49+
tags: |
50+
openebs/linux-utils:ci
4651
4752
- name: Run Trivy vulnerability scanner
4853
uses: aquasecurity/trivy-action@master

.github/workflows/release.yml

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,39 @@ jobs:
2525
- name: Checkout
2626
uses: actions/checkout@v1
2727

28-
- name: Set Tag
28+
- name: Set Image Org
29+
# sets the default IMAGE_ORG to openebs
30+
run: |
31+
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
32+
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
33+
34+
- name: Set Release Tag
2935
run: |
3036
TAG="${GITHUB_REF#refs/*/v}"
31-
echo "TAG=${TAG}" >> $GITHUB_ENV
3237
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
3338
39+
- name: Set Build Date
40+
id: date
41+
run: |
42+
echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')"
43+
44+
- name: Docker meta
45+
id: docker_meta
46+
uses: crazy-max/ghaction-docker-meta@v1
47+
with:
48+
# add each registry to which the image needs to be pushed here
49+
images: |
50+
${{ env.IMAGE_ORG }}/linux-utils
51+
quay.io/${{ env.IMAGE_ORG }}/linux-utils
52+
tag-latest: true
53+
tag-semver: |
54+
{{version}}
55+
56+
- name: Print Tags
57+
run: |
58+
echo "${{ steps.docker_meta.outputs.tags }}"
59+
echo "RELEASE TAG: ${RELEASE_TAG}"
60+
3461
- name: Setup QEMU
3562
uses: docker/setup-qemu-action@v1
3663
with:
@@ -48,22 +75,37 @@ jobs:
4875
username: ${{ secrets.DOCKERHUB_USERNAME }}
4976
password: ${{ secrets.DOCKERHUB_TOKEN }}
5077

78+
- name: Login to Quay
79+
uses: docker/login-action@v1
80+
with:
81+
registry: quay.io
82+
username: ${{ secrets.QUAY_USERNAME }}
83+
password: ${{ secrets.QUAY_TOKEN }}
84+
5185
- name: Build & Push Image
52-
run: |
53-
make buildx.image
54-
make buildx.push
86+
uses: docker/build-push-action@v2
87+
with:
88+
file: ./Dockerfile
89+
push: true
90+
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
91+
tags: |
92+
${{ steps.docker_meta.outputs.tags }}
93+
build-args: |
94+
DBUILD_DATE=${{ steps.date.outputs.DATE }}
95+
DBUILD_REPO_URL=https://github.com/openebs/linux-utils
96+
DBUILD_SITE_URL=https://openebs.io
97+
RELEASE_TAG=${RELEASE_TAG}
5598
5699
trivy:
57-
runs-on: ubuntu-18.04
100+
runs-on: ubuntu-latest
58101
needs: ['linux-utils']
59102
steps:
60103
- name: Checkout code
61104
uses: actions/checkout@v2
62105

63-
- name: Set Tag
106+
- name: Set Release Tag
64107
run: |
65108
TAG="${GITHUB_REF#refs/*/v}"
66-
echo "TAG=${TAG}" >> $GITHUB_ENV
67109
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
68110
69111
- name: Run Trivy vulnerability scanner

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.12.0
1+
FROM alpine:3.12.4
22
RUN apk add --no-cache util-linux
33

44
ARG DBUILD_DATE

0 commit comments

Comments
 (0)