Skip to content

Commit

Permalink
Reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Bouijoux committed Feb 14, 2024
1 parent 43b2aec commit bbb9e9b
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 116 deletions.
48 changes: 10 additions & 38 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
48 changes: 10 additions & 38 deletions .github/workflows/build-incus-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
52 changes: 12 additions & 40 deletions .github/workflows/build-lxc-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/build-rootfs.yaml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions .github/workflows/checkout-self-hosted.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bbb9e9b

Please sign in to comment.