-
Notifications
You must be signed in to change notification settings - Fork 3
42 lines (40 loc) · 1.38 KB
/
push.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
name: Build & Push Container Image
on:
push:
branches:
- master
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
env:
IMAGE: docker.io/vshn/modsecurity
QUAY_IMAGE: quay.io/vshn/modsecurity
steps:
- uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Set version latest
if: github.ref == 'refs/heads/master'
run: echo "VERSION=latest" >> ${GITHUB_ENV}
- name: Set version from tag
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> ${GITHUB_ENV}
- name: Build Image
run: docker build -t "${IMAGE}:${VERSION}" v3.3
- name: Push Image to DockerHub
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
docker login docker.io --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}"
docker push "${IMAGE}:${VERSION}"
- name: Push Image to Quay
env:
DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
run: |
docker login quay.io --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}"
docker tag "${IMAGE}:${VERSION}" ${QUAY_IMAGE}:${VERSION}
docker push "${QUAY_IMAGE}:${VERSION}"