Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace quay.io with ghcr.io #135

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 36 additions & 31 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,44 @@ on:
branches:
- master
tags:
- v*
- "v*"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
# Push image to GitHub Packages.
container:
runs-on: ubuntu-latest
env:
IMAGE: docker.io/vshn/modsecurity
QUAY_IMAGE: quay.io/vshn/modsecurity
permissions:
contents: read
packages: write

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}"
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine Tags & Labels based on Git ref
id: meta
uses: docker/metadata-action@v5
with:
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"

- name: Build & Push container image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
addLatest: true