-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anatolii Bazko <[email protected]>
- Loading branch information
Showing
1 changed file
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# | ||
# Copyright (c) 2021-2025 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
|
||
name: Pull Request Check | ||
|
||
# Trigger the workflow on pull request | ||
on: [pull_request] | ||
|
||
jobs: | ||
build_base_ubi9_image: | ||
name: Build BDI9 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm'] | ||
runs-on: ${{matrix.runners}} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set arch environment variable | ||
run: | | ||
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then | ||
echo arch="amd64" >> $GITHUB_ENV | ||
else | ||
echo arch="arm64" >> $GITHUB_ENV | ||
fi | ||
- name: Free runner space | ||
run: sudo rm -rf /usr/local/lib/android | ||
- name: Cleanup docker images | ||
run: docker system prune -af | ||
- name: Docker BDI9 image | ||
run: | | ||
cd base/ubi9 && docker buildx build \ | ||
--platform linux/${{env.arch}} \ | ||
--progress=plain \ | ||
-t base-developer-image-${{env.arch}} . | ||
- name: Display docker images | ||
run: docker images | ||
- name: Compress image to a file | ||
run: docker save base-developer-image-${{env.arch}} | gzip > base-developer-image-${{env.arch}}.tgz | ||
- name: Upload image artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: base-developer-image-${{env.arch}} | ||
path: base-developer-image-${{env.arch}}.tgz | ||
|
||
build_universal_ubi9_image: | ||
name: Build UDI9 image | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm'] | ||
runs-on: ${{matrix.runners}} | ||
needs: build_base_ubi9_image | ||
steps: | ||
- name: Set arch environment variable | ||
run: | | ||
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then | ||
echo arch="amd64" >> $GITHUB_ENV | ||
else | ||
echo arch="arm64" >> $GITHUB_ENV | ||
fi | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Free runner space | ||
run: sudo rm -rf /usr/local/lib/android | ||
- name: Cleanup docker images | ||
run: docker system prune -af | ||
- name: Download BDI artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: base-developer-image-* | ||
merge-multiple: true | ||
path: . | ||
- name: List downloaded files | ||
run: ls -lah | ||
- name: Load docker images | ||
run: docker load -i base-developer-image-${{env.arch}}.tgz | ||
- name: Display docker images | ||
run: docker images | ||
- name: Update UDI Dockerfile | ||
run: sed "s|quay.io/devfile/base-developer-image:ubi9-latest|base-developer-image-${{env.arch}}|" -i "universal/ubi9/Dockerfile" | ||
- name: Login to Quay.io | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_PASSWORD }} | ||
- name: Build UDI9 image | ||
run: | | ||
cd universal/ubi9 && docker buildx build \ | ||
--platform linux/${{env.arch}} \ | ||
--progress=plain \ | ||
--push \ | ||
-t quay.io/devfile/universal-developer-image:${{env.arch}}-pr-${{github.event.number}} . | ||
publish-images: | ||
name: publish image from the pull request | ||
runs-on: ubuntu-22.04 | ||
needs: build_universal_ubi9_image | ||
steps: | ||
- name: Login to Quay.io | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_PASSWORD }} | ||
- name: publish | ||
run: | | ||
docker manifest create quay.io/devfile/universal-developer-image:pr-${{github.event.number}} \ | ||
--amend quay.io/devfile/universal-developer-image:amd64-pr-${{github.event.number}} \ | ||
--amend quay.io/devfile/universal-developer-image:arm64-pr-${{github.event.number}} | ||
docker manifest annotate quay.io/devfile/universal-developer-image:pr-${{github.event.number}} \ | ||
quay.io/devfile/universal-developer-image:amd64-pr-${{github.event.number}} \ | ||
--os linux --arch amd64 | ||
docker manifest annotate quay.io/devfile/universal-developer-image:pr-${{github.event.number}} \ | ||
quay.io/devfile/universal-developer-image:arm64-pr-${{github.event.number}} \ | ||
--os linux --arch arm64 | ||
docker manifest push quay.io/devfile/universal-developer-image:pr-${{github.event.number}} | ||
- name: 'Comment PR' | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { repo: { owner, repo } } = context; | ||
await github.rest.issues.createComment({ | ||
issue_number: ${{github.event.number}}, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: `Pull Request images published ✨\n\nUDI: [quay.io/devfile/universal-developer-image:pr-${{github.event.number}}](https://quay.io/devfile/universal-developer-image:pr-${{github.event.number}})` | ||
}) |