Skip to content

Commit

Permalink
Reusable workflows
Browse files Browse the repository at this point in the history
Names to jobs
  • Loading branch information
Alexandre Bouijoux committed Feb 14, 2024
1 parent 43b2aec commit b03cd1a
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 110 deletions.
47 changes: 11 additions & 36 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,19 @@ 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:
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
uses: ./.github/workflows/checkout-self-hosted.yaml

build-rootfs:
name: 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 +27,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
47 changes: 11 additions & 36 deletions .github/workflows/build-incus-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,19 @@ 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:
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:
uses: ./.github/workflows/checkout-self-hosted.yaml

build-rootfs:
name: 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 @@ -55,6 +29,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
51 changes: 13 additions & 38 deletions .github/workflows/build-lxc-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,19 @@ 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:
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:
uses: ./.github/workflows/checkout-self-hosted.yaml

build-rootfs:
name: 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 @@ -55,9 +28,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 b03cd1a

Please sign in to comment.