Reviewers #104
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v4 | |
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}" | |