diff --git a/.github/workflows/build-oci.yaml b/.github/workflows/build-oci.yaml index ef7804273..dea51258f 100644 --- a/.github/workflows/build-oci.yaml +++ b/.github/workflows/build-oci.yaml @@ -9,41 +9,66 @@ on: branches: [ main ] jobs: - build-mapt: - name: build-mapt + build: + name: build 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: Build and Push image for Release + if: github.event_name == 'push' + run: | + make oci-build + make oci-save + + - name: Upload mapt artifacts for PR + uses: actions/upload-artifact@v4 + with: + name: mapt + path: mapt* + + push: + name: push + if: github.event_name == 'push' + needs: build + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download mapt oci flatten images + uses: actions/download-artifact@v4 + with: + name: mapt + + - name: Log in quay.io + uses: redhat-actions/podman-login@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_IO_USERNAME }} + password: ${{ secrets.QUAY_IO_PASSWORD }} + + - name: Push image for Release + if: github.event_name == 'push' + run: | + make oci-load + make oci-push + + diff --git a/.github/workflows/push-oci-pr.yml b/.github/workflows/push-oci-pr.yml new file mode 100644 index 000000000..5c29ccebd --- /dev/null +++ b/.github/workflows/push-oci-pr.yml @@ -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 }} diff --git a/.github/workflows/push-oci.yml b/.github/workflows/push-oci.yml deleted file mode 100644 index a0e80586b..000000000 --- a/.github/workflows/push-oci.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: oci-push - -on: - workflow_run: - workflows: - - oci-builds - types: - - completed - -jobs: - push: - name: push - if: | - github.event.workflow_run.conclusion == 'success' - 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 "source_event=$(cat mapt-event)" >> "$GITHUB_ENV" - echo "image=$(cat mapt-image)" >> "$GITHUB_ENV" - - - name: Log in to ghcr.io - if: ${{ env.source_event == 'pull_request' }} - uses: redhat-actions/podman-login@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Log in quay.io - if: ${{ env.source_event == 'push' }} - uses: redhat-actions/podman-login@v1 - with: - registry: quay.io - username: ${{ secrets.QUAY_IO_USERNAME }} - password: ${{ secrets.QUAY_IO_PASSWORD }} - - - 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 }})