Skip to content

Commit 57d8173

Browse files
committed
fix: issues while pushing mapt image for PRs and releases
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]>
1 parent 892b9f5 commit 57d8173

File tree

3 files changed

+113
-98
lines changed

3 files changed

+113
-98
lines changed

.github/workflows/build-oci.yaml

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,66 @@ on:
99
branches: [ main ]
1010

1111
jobs:
12-
build-mapt:
13-
name: build-mapt
12+
build:
13+
name: build
1414
runs-on: ubuntu-24.04
1515
steps:
16-
- name: Prepare runner
17-
shell: bash
18-
run: |
19-
sudo apt-get update && sudo apt-get install -y qemu-user-static
20-
21-
- name: Checkout code
22-
uses: actions/checkout@v4
23-
24-
- name: Build image for PR
25-
if: ${{ github.event_name == 'pull_request' }}
26-
env:
27-
IMG: ghcr.io/redhat-developer/mapt:pr-${{ github.event.number }}
28-
shell: bash
29-
run: |
30-
make oci-build
31-
make oci-save
32-
echo ${IMG} > mapt-image
33-
34-
35-
- name: Build image for Release
36-
if: ${{ github.event_name == 'push' }}
37-
run: |
38-
make oci-build
39-
make oci-save
40-
41-
- name: Create image metadata
42-
run: |
43-
echo ${{ github.event_name }} > mapt-event
44-
45-
- name: Upload crc-builder
46-
uses: actions/upload-artifact@v4
47-
with:
48-
name: mapt
49-
path: mapt*
50-
16+
- name: Prepare runner for build multi arch
17+
shell: bash
18+
run: |
19+
sudo apt-get update && sudo apt-get install -y qemu-user-static
20+
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Build image for PR
25+
if: github.event_name == 'pull_request'
26+
env:
27+
IMG: ghcr.io/redhat-developer/mapt:pr-${{ github.event.number }}
28+
shell: bash
29+
run: |
30+
make oci-build
31+
make oci-save
32+
echo ${IMG} > mapt-image
33+
34+
- name: Build and Push image for Release
35+
if: github.event_name == 'push'
36+
run: |
37+
make oci-build
38+
make oci-save
39+
40+
- name: Upload mapt artifacts for PR
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: mapt
44+
path: mapt*
45+
46+
push:
47+
name: push
48+
if: github.event_name == 'push'
49+
needs: build
50+
runs-on: ubuntu-24.04
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v4
54+
55+
- name: Download mapt oci flatten images
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: mapt
59+
60+
- name: Log in quay.io
61+
uses: redhat-actions/podman-login@v1
62+
with:
63+
registry: quay.io
64+
username: ${{ secrets.QUAY_IO_USERNAME }}
65+
password: ${{ secrets.QUAY_IO_PASSWORD }}
66+
67+
- name: Push image for Release
68+
if: github.event_name == 'push'
69+
run: |
70+
make oci-load
71+
make oci-push
72+
73+
74+

.github/workflows/push-oci-pr.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: oci-pr-push
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- oci-builds
7+
types:
8+
- completed
9+
10+
jobs:
11+
push:
12+
name: push
13+
if: |
14+
github.event.workflow_run.conclusion == 'success' &&
15+
github.event.workflow_run.event == 'pull_request'
16+
runs-on: ubuntu-24.04
17+
permissions:
18+
contents: read
19+
packages: write
20+
steps:
21+
- name: Download mapt assets
22+
uses: actions/download-artifact@v4
23+
with:
24+
name: mapt
25+
run-id: ${{ github.event.workflow_run.id }}
26+
github-token: ${{ github.token }}
27+
28+
- name: Get mapt build informaiton
29+
run: |
30+
echo "image=$(cat mapt-image)" >> "$GITHUB_ENV"
31+
32+
- name: Log in to ghcr.io
33+
uses: redhat-actions/podman-login@v1
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
40+
- name: Push mapt
41+
run: |
42+
# Load images from build
43+
podman load -i mapt-arm64.tar
44+
podman load -i mapt-amd64.tar
45+
46+
# Push
47+
podman push ${{ env.image }}-arm64
48+
podman push ${{ env.image }}-amd64
49+
podman manifest create ${{ env.image }}
50+
podman manifest add ${{ env.image }} docker://${{ env.image }}-arm64
51+
podman manifest add ${{ env.image }} docker://${{ env.image }}-amd64
52+
podman manifest push --all ${{ env.image }}

.github/workflows/push-oci.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)