From a28118751cb5058e214068168cc3a7d07e8cd0d0 Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Fri, 8 Sep 2023 16:56:10 -0300 Subject: [PATCH] workflows/podvm: configurable registry Added the `registry` parameter to the builder/binaries/podvm workflows to allow publish the images in an arbitrary registry. Also added login handler if the registry is `ghcr.io`. Signed-off-by: Wainer dos Santos Moschetta --- .github/workflows/podvm.yaml | 15 +++++++++++++++ .github/workflows/podvm_binaries.yaml | 15 +++++++++++++++ .github/workflows/podvm_builder.yaml | 15 +++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/.github/workflows/podvm.yaml b/.github/workflows/podvm.yaml index 37ae68464..721a745f6 100644 --- a/.github/workflows/podvm.yaml +++ b/.github/workflows/podvm.yaml @@ -1,6 +1,11 @@ name: Create Pod VM Image on: workflow_call: + inputs: + registry: + default: 'quay.io/confidential-containers' + required: false + type: string jobs: build: @@ -31,15 +36,25 @@ jobs: - name: Login to Quay container Registry uses: docker/login-action@v2 + if: ${{ startsWith(inputs.registry, 'quay.io') }} with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} + - name: Login to Github Container Registry + if: ${{ startsWith(inputs.registry, 'ghcr.io') }} + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push run: make podvm-image env: PUSH: true + REGISTRY: ${{ inputs.registry }} ARCH: ${{ matrix.arch }} PODVM_DISTRO: ${{ matrix.os }} CLOUD_PROVIDER: ${{ matrix.provider }} diff --git a/.github/workflows/podvm_binaries.yaml b/.github/workflows/podvm_binaries.yaml index fae5e87a6..0b1786c65 100644 --- a/.github/workflows/podvm_binaries.yaml +++ b/.github/workflows/podvm_binaries.yaml @@ -1,6 +1,11 @@ name: Create Pod VM Binaries Image on: workflow_call: + inputs: + registry: + default: 'quay.io/confidential-containers' + required: false + type: string jobs: build: @@ -32,15 +37,25 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Login to Quay container Registry + if: ${{ startsWith(inputs.registry, 'quay.io') }} uses: docker/login-action@v2 with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} + - name: Login to Github Container Registry + if: ${{ startsWith(inputs.registry, 'ghcr.io') }} + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push run: make podvm-binaries env: PUSH: true + REGISTRY: ${{ inputs.registry }} ARCH: ${{ matrix.arch }} PODVM_DISTRO: ${{ matrix.os }} diff --git a/.github/workflows/podvm_builder.yaml b/.github/workflows/podvm_builder.yaml index 73d2dafcf..bf894ec36 100644 --- a/.github/workflows/podvm_builder.yaml +++ b/.github/workflows/podvm_builder.yaml @@ -1,6 +1,11 @@ name: Create Pod VM Builder Image on: workflow_call: + inputs: + registry: + default: 'quay.io/confidential-containers' + required: false + type: string jobs: build: @@ -30,14 +35,24 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Login to Quay container Registry + if: ${{ startsWith(inputs.registry, 'quay.io') }} uses: docker/login-action@v2 with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} + - name: Login to Github Container Registry + if: ${{ startsWith(inputs.registry, 'ghcr.io') }} + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push run: make podvm-builder env: PUSH: true + REGISTRY: ${{ inputs.registry }} PODVM_DISTRO: ${{ matrix.os }}