Skip to content

Commit

Permalink
fix: issues while pushing mapt image for PRs and releases
Browse files Browse the repository at this point in the history
This commit will split the push behavior, from on build and push for Release will happen on build-oci action, meanwhile build for PR will be mange on build-oci and push to ghcr is done on a push-oci-pr

Signed-off-by: Adrian Riobo <[email protected]>
  • Loading branch information
adrianriobo committed Dec 18, 2024
1 parent f2f3679 commit 2639360
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 94 deletions.
73 changes: 40 additions & 33 deletions .github/workflows/build-oci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,44 @@ jobs:
name: build-mapt
runs-on: ubuntu-24.04
steps:
- name: Prepare runner
shell: bash
run: |
sudo apt-get update && sudo apt-get install -y qemu-user-static
- name: Checkout code
uses: actions/checkout@v4

- name: Build image for PR
if: ${{ github.event_name == 'pull_request' }}
env:
IMG: ghcr.io/redhat-developer/mapt:pr-${{ github.event.number }}
shell: bash
run: |
make oci-build
make oci-save
echo ${IMG} > mapt-image
- name: Build image for Release
if: ${{ github.event_name == 'push' }}
run: |
make oci-build
make oci-save
- name: Create image metadata
run: |
echo ${{ github.event_name }} > mapt-event
- name: Upload crc-builder
uses: actions/upload-artifact@v4
with:
name: mapt
path: mapt*
- name: Prepare runner for build multi arch
shell: bash
run: |
sudo apt-get update && sudo apt-get install -y qemu-user-static
- name: Checkout code
uses: actions/checkout@v4

- name: Build image for PR
if: github.event_name == 'pull_request'
env:
IMG: ghcr.io/redhat-developer/mapt:pr-${{ github.event.number }}
shell: bash
run: |
make oci-build
make oci-save
echo ${IMG} > mapt-image
- name: Upload mapt artifacts for PR
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: mapt
path: mapt*

- name: Log in quay.io
if: github.event_name == 'push'
uses: redhat-actions/podman-login@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_IO_USERNAME }}
password: ${{ secrets.QUAY_IO_PASSWORD }}

- name: Build and Push image for Release
if: github.event_name == 'push'
run: |
make oci-build
make oci-push

52 changes: 52 additions & 0 deletions .github/workflows/push-oci-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: oci-pr-push

on:
workflow_run:
workflows:
- oci-builds
types:
- completed

jobs:
push:
name: push
if: |
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Download mapt assets
uses: actions/download-artifact@v4
with:
name: mapt
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: Get mapt build informaiton
run: |
echo "image=$(cat mapt-image)" >> "$GITHUB_ENV"
- name: Log in to ghcr.io
uses: redhat-actions/podman-login@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Push mapt
run: |
# Load images from build
podman load -i mapt-arm64.tar
podman load -i mapt-amd64.tar
# Push
podman push ${{ env.image }}-arm64
podman push ${{ env.image }}-amd64
podman manifest create ${{ env.image }}
podman manifest add ${{ env.image }} docker://${{ env.image }}-arm64
podman manifest add ${{ env.image }} docker://${{ env.image }}-amd64
podman manifest push --all ${{ env.image }}
61 changes: 0 additions & 61 deletions .github/workflows/push-oci.yml

This file was deleted.

0 comments on commit 2639360

Please sign in to comment.