Skip to content

Commit

Permalink
Rework GitHub workflows (#119)
Browse files Browse the repository at this point in the history
* ci: add build action for PRs
* ci: use matrix job for build and review
* ci: use matrix job for dockerhub description
  • Loading branch information
mkuf committed Mar 3, 2024
1 parent df3be95 commit 66b8e09
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 222 deletions.
37 changes: 37 additions & 0 deletions .github/actions/image-build-common/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "image-build-common"
description: "Common runner setup to build Container Images for prind"

runs:
using: "composite"
steps:
- name: "[misc] Clean Runner"
shell: bash
run: |
set -x
## Remove files
to_delete=(
"/swapfile"
"/usr/local/share/boost"
"$AGENT_TOOLSDIRECTORY"
"/usr/share/dotnet"
"$ANDROID_SDK_ROOT"
"/usr/local/lib/android"
"$ANDROID_SDK_ROOT"
"/usr/share/swift"
)
for f in ${to_delete[@]}; do
sudo rm -rf ${f} || true
done
## Clean docker
docker system prune --all --volumes --force
- name: "[docker] set up qemu"
uses: docker/setup-qemu-action@v2.2.0

- name: "[docker] set up buildx"
uses: docker/setup-buildx-action@v2.7.0

- name: "[prind] install requirements"
shell: bash
run: pip install -r scripts/build/requirements.txt
35 changes: 35 additions & 0 deletions .github/workflows/image-build-and-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Build and Publish Images'
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * *'
jobs:
build:
strategy:
matrix:
app:
- klipper
- klipperscreen
- moonraker
- ustreamer
runs-on: ubuntu-latest
steps:
- name: "[prind] checkout"
uses: actions/checkout@v3
- name: "[prind] set up build environment"
uses: ./.github/actions/image-build-common
- name: "[docker] login"
uses: docker/login-action@v2.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "[prind] build"
run: |
python3 scripts/build/build.py ${{ matrix.app }} \
--backfill 3 \
--platform linux/amd64 \
--platform linux/arm/v6 \
--platform linux/arm/v7 \
--platform linux/arm64/v8 \
--registry docker.io/${{ secrets.DOCKERHUB_USERNAME }} \
--push
13 changes: 0 additions & 13 deletions .github/workflows/image-build-klipper.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/image-build-klipperscreen.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/image-build-moonraker.yaml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/image-build-review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: 'Build Images for Review'
on:
pull_request:
paths:
- .github/workflows/image-build-review.yaml
- scripts/build/**
- docker/**

jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
apps: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
klipper:
- .github/workflows/image-build-review.yaml
- scripts/build/**
- docker/klipper/**
klipperscreen:
- .github/workflows/image-build-review.yaml
- scripts/build/**
- docker/klipperscreen/**
moonraker:
- .github/workflows/image-build-review.yaml
- scripts/build/**
- docker/moonraker/**
ustreamer:
- .github/workflows/image-build-review.yaml
- scripts/build/**
- docker/ustreamer/**
build:
needs: changes
strategy:
matrix:
app: ${{ fromJSON(needs.changes.outputs.apps) }}
runs-on: ubuntu-latest
steps:
- name: "[prind] checkout"
uses: actions/checkout@v3
- name: "[prind] set up build environment"
uses: ./.github/actions/image-build-common
- name: "[prind] build"
run: |
python3 scripts/build/build.py ${{ matrix.app }} \
--backfill 0 \
--platform linux/amd64 \
--platform linux/arm/v6 \
--platform linux/arm/v7 \
--platform linux/arm64/v8 \
--force
13 changes: 0 additions & 13 deletions .github/workflows/image-build-ustreamer.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/image-docs-klipper.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/image-docs-klipperscreen.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/image-docs-moonraker.yaml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/image-docs-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Update Image Description at Dockerhub"

on:
push:
branches:
- main
paths:
- .github/workflows/image-docs-publish.yaml
- docker/**/README.md

jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
apps: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
klipper:
- .github/workflows/image-docs-publish.yaml
- docker/klipper/README.md
klipperscreen:
- .github/workflows/image-docs-publish.yaml
- docker/klipperscreen/README.md
moonraker:
- .github/workflows/image-docs-publish.yaml
- docker/moonraker/README.md
ustreamer:
- .github/workflows/image-docs-publish.yaml
- docker/moonraker/README.md
dockerhub-description:
needs: changes
strategy:
matrix:
app: ${{ fromJSON(needs.changes.outputs.apps) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Update Docker Hub Description"
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.app }}
readme-filepath: ./docker/${{ matrix.app }}/README.md
enable-url-completion: true
18 changes: 0 additions & 18 deletions .github/workflows/image-docs-ustreamer.yaml

This file was deleted.

66 changes: 0 additions & 66 deletions .github/workflows/template-image-build-workflow.yaml

This file was deleted.

Loading

0 comments on commit 66b8e09

Please sign in to comment.