mirror of
https://github.com/Gradiant/5g-images.git
synced 2025-10-23 00:02:08 +00:00
* Updating version ueransim [3.2.6 -> 3.2.7] * updates Ubuntu version to fix gcc error * changes github runner OS version to fix segfault --------- Co-authored-by: aebarreiro <aebarreiro@users.noreply.github.com> Co-authored-by: Álvaro Vázquez <avrodriguez@gradiant.org>
100 lines
3.3 KiB
YAML
100 lines
3.3 KiB
YAML
name: build images
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'images/**'
|
|
- '!images/**/update_current_tag.sh'
|
|
|
|
env:
|
|
images_dir: images
|
|
|
|
jobs:
|
|
# Generate the values for images with changes
|
|
generate-matrix:
|
|
runs-on: ubuntu-22.04
|
|
outputs:
|
|
matrix: ${{ steps.generate-matrix.outputs.matrix }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- id: files
|
|
uses: tj-actions/changed-files@v17.3
|
|
- name: Generate Matrix Content
|
|
id: generate-matrix
|
|
run: |
|
|
changed=`echo "${{ steps.files.outputs.all_changed_files }}" | sed 's/ /\n/g' | grep $images_dir | cut -f2 -d'/' | uniq | sed 's/^/"/;s/$/"/' | sed -z 's/\n/,/g;s/,$/\n/'`
|
|
echo "matrix={ \"image\": [ ${changed} ] }" >> $GITHUB_OUTPUT
|
|
|
|
# build image if changes in code
|
|
build-image:
|
|
needs: generate-matrix
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix: ${{ fromJson( needs.generate-matrix.outputs.matrix ) }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Get Image Info
|
|
id: image-info
|
|
run: |
|
|
source ./images/${{ matrix.image }}/image_info.sh
|
|
echo "platforms=$PLATFORMS" >> $GITHUB_OUTPUT
|
|
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
|
|
echo "image=${{ matrix.image }}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3.4.0
|
|
with:
|
|
image: tonistiigi/binfmt:qemu-v7.0.0-28
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3.9.0
|
|
-
|
|
name: Build and push
|
|
uses: docker/build-push-action@v6.13.0
|
|
with:
|
|
context: ./images/${{ steps.image-info.outputs.image }}/
|
|
push: false
|
|
tags: gradiant/${{ steps.image-info.outputs.image }}:${{ steps.image-info.outputs.image_tag }}
|
|
build-args: version=${{ steps.image-info.outputs.image_tag }}
|
|
platforms: ${{ steps.image-info.outputs.platforms }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Check for ubi Dockerfile
|
|
id: ubi_dockerfile
|
|
run: |
|
|
if test -f "images/${{ matrix.image }}/Dockerfile.ubi"; then
|
|
echo "build_ubi=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "build_ubi=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Login to RedHat Registry
|
|
if: steps.ubi_dockerfile.outputs.build_ubi == 'true'
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: registry.redhat.io
|
|
username: ${{ secrets.REDHAT_USERNAME }}
|
|
password: ${{ secrets.REDHAT_PASSWORD }}
|
|
|
|
- name: Build and push
|
|
if: steps.ubi_dockerfile.outputs.build_ubi == 'true'
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: ./images/${{ steps.image-info.outputs.image }}/
|
|
file: ./images/${{ steps.image-info.outputs.image }}/Dockerfile.ubi
|
|
push: false
|
|
tags: gradiant/${{ steps.image-info.outputs.image }}:${{ steps.image-info.outputs.image_tag }}-ubi
|
|
build-args: version=${{ steps.image-info.outputs.image_tag }}
|
|
platforms: ${{ steps.image-info.outputs.platforms }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|