From beadf8eff10730533903b297e2f76ec4e622d471 Mon Sep 17 00:00:00 2001 From: Alexandre Bouijoux Date: Wed, 14 Feb 2024 19:22:47 +0100 Subject: [PATCH] Reusable workflows --- .github/workflows/build-lxc-image.yaml | 45 ++++----------------- .github/workflows/build-rootfs.yaml | 33 +++++++++++++++ .github/workflows/checkout-self-hosted.yaml | 20 +++++++++ 3 files changed, 61 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/build-rootfs.yaml create mode 100644 .github/workflows/checkout-self-hosted.yaml diff --git a/.github/workflows/build-lxc-image.yaml b/.github/workflows/build-lxc-image.yaml index ae78957..724fdfd 100644 --- a/.github/workflows/build-lxc-image.yaml +++ b/.github/workflows/build-lxc-image.yaml @@ -6,46 +6,17 @@ env: os: mageia jobs: - clean_stale_repo: - name: Clean stale repo - runs-on: self-hosted - steps: - - name: Clean stale repo - run: sudo rm -rf .* * || true - clone_repo: - name: Clone repo - runs-on: self-hosted - needs: clean_stale_repo - steps: - - name: Clone repo - uses: actions/checkout@v4 - craft_minimal_system: - name: Craft minimal system - runs-on: self-hosted - needs: clone_repo - steps: - - name: Cache squash-fs - id: squash-fs - uses: actions/cache@v4 - with: - path: ${{ env.os }}.sqfs - key: ${{ env.os }}.sqfs-${{ hashFiles('./Makefile') }} - - name: Make 'minimal-fs' - if: steps.squash-fs.outputs.cache-hit != 'true' - run: make minimal-fs - - name: Make 'squash-fs' - if: steps.squash-fs.outputs.cache-hit != 'true' - run: make squash-fs - - name: Upload image - if: steps.squash-fs.outputs.cache-hit != 'true' - uses: actions/upload-artifact@v4 - with: - name: ${{ env.os }}.sqfs - path: ${{ env.os }}.sqfs + clone-repo: + uses: ./.github/workflows/checkout-self-hosted.yaml + + build-rootfs: + needs: clone-repo + uses: ./.github/workflows/build-rootfs.yaml + build_for_target: name: Build for target runs-on: self-hosted - needs: craft_minimal_system + needs: build-rootfs steps: - name: Cache build id: build diff --git a/.github/workflows/build-rootfs.yaml b/.github/workflows/build-rootfs.yaml new file mode 100644 index 0000000..b3c7436 --- /dev/null +++ b/.github/workflows/build-rootfs.yaml @@ -0,0 +1,33 @@ +name: Build rootfs +on: + workflow_dispatch: + workflow_call: + +env: + os: mageia + +jobs: + build-rootfs: + name: Build rootfs + runs-on: self-hosted + steps: + - name: Cache squash fs + id: squash-fs + uses: actions/cache@v4 + with: + path: ${{ env.os }}.sqfs + key: ${{ env.os }}.sqfs-${{ hashFiles('./Makefile') }} + + - name: Make minimal-fs + if: steps.squash-fs.outputs.cache-hit != 'true' + run: make minimal-fs + + - name: Make squash-fs + if: steps.squash-fs.outputs.cache-hit != 'true' + run: make squash-fs + + - name: Upload image + uses: actions/upload-artifact@v4 + with: + name: ${{ env.os }}.sqfs + path: ${{ env.os }}.sqfs diff --git a/.github/workflows/checkout-self-hosted.yaml b/.github/workflows/checkout-self-hosted.yaml new file mode 100644 index 0000000..9f9d102 --- /dev/null +++ b/.github/workflows/checkout-self-hosted.yaml @@ -0,0 +1,20 @@ +name: Clean checkout +on: + workflow_dispatch: + workflow_call: + +jobs: + clean_stale_repo: + name: Clean stale repo + runs-on: self-hosted + steps: + - name: Clean stale repo + run: sudo rm -rf .* * || true + + clone-repo: + name: Clone repo + runs-on: self-hosted + needs: clean_stale_repo + steps: + - name: Clone repo + uses: actions/checkout@v4