1# SPDX-FileCopyrightText: Andrei Gherzan <andrei.gherzan@huawei.com>
2#
3# SPDX-License-Identifier: MIT
4
5---
6
7name: Builds
8
9on:
10  pull_request:
11
12jobs:
13  build:
14    strategy:
15      fail-fast: true
16      matrix:
17        machine:
18          - raspberrypi
19          - raspberrypi0-2w-64
20          - raspberrypi0-2w
21          - raspberrypi0
22          - raspberrypi0-wifi
23          - raspberrypi2
24          - raspberrypi3-64
25          - raspberrypi3
26          - raspberrypi4-64
27          - raspberrypi4
28          - raspberrypi5
29          - raspberrypi-cm3
30          - raspberrypi-cm
31          - raspberrypi-armv7
32          - raspberrypi-armv8
33        image: [rpi-test-image]
34        distro: [poky]
35    runs-on: [self-hosted, Linux]
36    name: ${{ matrix.machine }}/${{ matrix.image }}/poky/systemd
37    env:
38      DL_DIR: /var/lib/ci/yocto/downloads
39      SSTATE_DIR: /var/lib/ci/yocto/sstate
40    steps:
41      - name: Checkout the code
42        uses: actions/checkout@v3
43        with:
44          fetch-depth: 0
45      - name: Define Yocto build files
46        id: changed-files-specific
47        uses: tj-actions/changed-files@v24
48        with:
49          files: |
50            .github/actions/**
51            .github/workflows/docker-images/yocto-builder/**
52            .github/workflows/docker-images/*.sh
53            .github/workflows/yocto-builds.yml
54            classes/**
55            conf/**
56            dynamic-layers/**
57            files/**
58            lib/**
59            recipes-**
60            wic/**
61      - name: Build a temporary yocto-builder image
62        uses: ./.github/actions/docker-build
63        with:
64          docker_image: yocto-builder
65          id: ${{ github.event.number }}
66        if: steps.changed-files-specific.outputs.any_changed == 'true'
67      - name: Build the image
68        run: |
69          docker run --rm \
70            -v "$GITHUB_WORKSPACE:/work:ro" \
71            -v "$DL_DIR:$DL_DIR:rw" \
72            -v "$SSTATE_DIR:$SSTATE_DIR:rw" \
73            --env "BASE_REF=$GITHUB_BASE_REF" \
74            --env "MACHINE=${{ matrix.machine }}" \
75            --env "DISTRO=${{ matrix.distro }}" \
76            --env "IMAGE=${{ matrix.image }}" \
77            --env "DL_DIR=$DL_DIR" \
78            --env "SSTATE_DIR=$SSTATE_DIR" \
79            "yocto-builder-${{ github.event.number }}" \
80            /entrypoint-build.sh
81        if: steps.changed-files-specific.outputs.any_changed == 'true'
82      - name: Cleanup temporary docker image
83        uses: ./.github/actions/docker-clean-image
84        with:
85          docker_image: yocto-builder-${{ github.event.number }}
86        if: always()
87      - name: Cleanup dangling docker images
88        uses: ./.github/actions/docker-clean-dangling
89        if: always()
90