diff --git a/.github/workflows/build-docker-image.yaml b/.github/workflows/build-docker-image.yaml index a4536c4..0095d0c 100644 --- a/.github/workflows/build-docker-image.yaml +++ b/.github/workflows/build-docker-image.yaml @@ -6,46 +6,16 @@ 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 @@ -54,9 +24,11 @@ jobs: path: | ./docker.tar.xz key: image-${{ env.os }}-docker-${{ hashFiles('*.sqfs', '*.yaml') }} + - name: Make target 'build-docker' if: steps.build.outputs.cache-hit != 'true' run: make build-docker + - name: Upload image uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/build-incus-image.yaml b/.github/workflows/build-incus-image.yaml index e69969d..c24e42c 100644 --- a/.github/workflows/build-incus-image.yaml +++ b/.github/workflows/build-incus-image.yaml @@ -6,45 +6,16 @@ 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 - uses: actions/upload-artifact@v4 - with: - name: ${{ env.os }}.sqfs - path: ${{ env.os }}.sqfs - build_for_target: - name: Build for target + clone-repo: + uses: ./.github/workflows/checkout-self-hosted.yaml + + build-rootfs: + needs: clone-repo + uses: ./.github/workflows/build-rootfs.yaml + + build-for-target: runs-on: self-hosted - needs: craft_minimal_system + needs: build-rootfs steps: - name: Cache build id: build @@ -55,6 +26,7 @@ jobs: - name: Make target 'build-incus' if: steps.build.outputs.cache-hit != 'true' run: make build-incus + - name: Upload image uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/build-lxc-image.yaml b/.github/workflows/build-lxc-image.yaml index ae78957..e55f6b3 100644 --- a/.github/workflows/build-lxc-image.yaml +++ b/.github/workflows/build-lxc-image.yaml @@ -6,46 +6,16 @@ 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 - build_for_target: - name: Build for target + clone-repo: + uses: ./.github/workflows/checkout-self-hosted.yaml + + build-rootfs: + needs: clone-repo + uses: ./.github/workflows/build-rootfs.yaml + + build-for-target: runs-on: self-hosted - needs: craft_minimal_system + needs: build-rootfs steps: - name: Cache build id: build @@ -55,9 +25,11 @@ jobs: ./out/rootfs.tar.xz ./out/meta.tar.xz key: image-${{ env.os }}-lxc-${{ hashFiles('*.sqfs', '*.yaml') }} - - name: Make target 'build-lxc' + + - name: Make build-lxc if: steps.build.outputs.cache-hit != 'true' run: make build-lxc + - name: Upload image uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/build-rootfs.yaml b/.github/workflows/build-rootfs.yaml new file mode 100644 index 0000000..6b41d73 --- /dev/null +++ b/.github/workflows/build-rootfs.yaml @@ -0,0 +1,34 @@ +name: Build rootfs +on: + workflow_call: + +env: + os: mageia + +jobs: + # Checkout repository is needed before use. + # See checkout-self-hosted.yaml + 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..07ba903 --- /dev/null +++ b/.github/workflows/checkout-self-hosted.yaml @@ -0,0 +1,19 @@ +name: Checkout repository +on: + 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