From e06816fccac94840d37b1bc4b3d34e93d45f2605 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Thu, 21 Apr 2022 17:30:03 +0200 Subject: [PATCH] CI: Build and push container image on PR and merge JIRA: RHELWF-6470 --- .github/workflows/gating.yaml | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gating.yaml b/.github/workflows/gating.yaml index bd6038f7..cb7eb7e1 100644 --- a/.github/workflows/gating.yaml +++ b/.github/workflows/gating.yaml @@ -15,7 +15,7 @@ jobs: python-version: ["3.10"] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 @@ -66,7 +66,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 @@ -99,3 +99,41 @@ jobs: # * DL3041 - Specify version with dnf install -y - ignore: DL3041 failure-threshold: warning + + image-build: + name: Container Image Build + needs: hadolint + runs-on: ubuntu-latest + env: + IMAGE_NAME: greenwave + REGISTRY: quay.io/factory2 + GH_REGISTRY: ghcr.io/${{ github.actor }} + + steps: + - uses: actions/checkout@v2 + + - name: Build Image + id: build-image + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.IMAGE_NAME }} + tags: >- + ${{ github.ref == 'refs/heads/master' && 'latest' || '' }} + ${{ github.sha }} + containerfiles: Dockerfile + + - name: Log in to the image registry + if: github.event_name == 'push' + uses: redhat-actions/podman-login@v1 + with: + registry: ${{ secrets.REGISTRY_USER && env.REGISTRY || env.GH_REGISTRY }} + username: ${{ secrets.REGISTRY_USER || github.actor }} + password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }} + + - name: Push Image + if: github.event_name == 'push' + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build-image.outputs.image }} + tags: ${{ steps.build-image.outputs.tags }} + registry: ${{ secrets.REGISTRY_USER && env.REGISTRY || env.GH_REGISTRY }}