Skip to content

Bugfix EGW and only build images if needed #88

Bugfix EGW and only build images if needed

Bugfix EGW and only build images if needed #88

Workflow file for this run

name: Image build
on:
pull_request: {}
push:
branches:
- main
jobs:
generate-matrix:
name: Create build matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: Checkout Source Code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- name: Check code changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
if: ${{ github.event_name == 'pull_request' }}
id: changes
with:
# These filter names must be synced with the `name` attribute for
# each entry in images.json.
filters: |
all:
- '.github/images.json'
- '.github/workflows/build.yaml'
cmapisrv-mock:
- 'cmapisrv-mock/**'
egw-scale-utils:
- 'egw-scale-utils/**'
- name: Generate matrix
id: generate-matrix
run: |
if [[ "${{ github.event_name }}" == "push" || "${{ steps.changes.outputs.all }}" == "true" ]]; then
echo "Using full matrix"
jq -c . ./.github/images.json > /tmp/matrix.json
else
echo "Building matrix from changes"
jq -c '{"include": [ .include[] | select(any(.name == ${{ steps.changes.outputs.changes }}[]; .)) ]}' ./.github/images.json > /tmp/matrix.json
fi
echo "Final matrix:"
jq . /tmp/matrix.json
echo "matrix=$(jq -c . /tmp/matrix.json)" >> $GITHUB_OUTPUT
build-and-push:
name: Build and Push
runs-on: ubuntu-latest
needs: generate-matrix
strategy:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
- name: Login to quay.io
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
if: ${{ github.event_name == 'push' }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME_SCAFFOLDING }}
password: ${{ secrets.QUAY_PASSWORD_SCAFFOLDING }}
- name: Checkout Source Code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- name: Generate image tags
id: tag
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_name }}" == "main" && "${{ github.repository }}" == "cilium/cilium" ]]; then
tag="latest"
else
tag="${{ github.event.pull_request.head.sha || github.sha }}"
fi
echo "tag=quay.io/${{ github.repository_owner }}/${{ matrix.name }}:${tag}" >> $GITHUB_OUTPUT
- name: Build and Push
uses: docker/build-push-action@16ebe778df0e7752d2cfcbd924afdbbd89c1a755 # v6.6.1
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name == 'push' }}
platforms: linux/amd64,linux/arm64
tags: |
${{ steps.tag.outputs.tag }}