From a038a35f9a52b01cc85cf575286d9e7276de051d Mon Sep 17 00:00:00 2001 From: meanmail Date: Thu, 7 Nov 2024 13:12:09 +0100 Subject: [PATCH] Refactor CI workflow for image builds Consolidate multiple build jobs into matrix builds for better maintainability. This refactoring simplifies the YAML structure and reduces redundancy by making the workflow more modular and less repetitive. --- .github/workflows/ci.yml | 411 +++++---------------------------------- 1 file changed, 54 insertions(+), 357 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b530f9..7cc7d96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,40 +26,22 @@ jobs: username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} add_hash: false - build_clojure_image: - name: Build epicbox-clojure image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-clojure - image_name: clojure - image_tag: tools-deps-1.11.1.1413-alpine - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_gcc_image: - name: Build epicbox-gcc image + + build_debian_images: + name: Build ${{ matrix.path }} image needs: build_debian_image runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-gcc + strategy: + matrix: + - path: epicbox-gcc image_name: gcc image_tag: 10.2.1-1 - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_go_image: - name: Build epicbox-go image - runs-on: [ self-hosted, small ] + - path: epicbox-hyperskill/gcc + image_name: hyperskill-gcc + image_tag: 10.2.1-1 + - path: epicbox-mono + image_name: mono + image_tag: 6.10.0.104 timeout-minutes: 15 steps: - name: Checkout code @@ -67,347 +49,86 @@ jobs: - name: Build uses: ./.github/workflows/actions/build with: - path: epicbox-go - image_name: go - image_tag: 1.21-bullseye + path: ${{ matrix.path }} + image_name: ${{ matrix.image_name }} + image_tag: ${{ matrix.image_tag }} username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} - build_haskell_image: - name: Build epicbox-haskell image + + build_images: + name: Build ${{ matrix.path }} image runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-haskell + strategy: + matrix: + - path: epicbox-clojure + image_name: clojure + image_tag: tools-deps-1.11.1.1413-alpine + - path: epicbox-go + image_name: go + image_tag: 1.21-bullseye + - path: epicbox-haskell image_name: haskell image_tag: 8.8.4 - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_hyperskill_go_image: - name: Build epicbox-hyperskill/go image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-hyperskill/go + - path: epicbox-hyperskill/go image_name: hyperskill-go image_tag: 1.21-bullseye - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_hyperskill_gcc_image: - name: Build epicbox-hyperskill/gcc image - needs: build_debian_image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-hyperskill/gcc - image_name: hyperskill-gcc - image_tag: 10.2.1-1 - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_hyperskill_gradle_image: - name: Build epicbox-hyperskill/gradle image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-hyperskill/gradle + - path: epicbox-hyperskill/gradle image_name: hyperskill-gradle image_tag: 8.5.0-jdk17 - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_hyperskill_gradle_spring_image: - name: Build epicbox-hyperskill/gradle-spring image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-hyperskill/gradle-spring + - path: epicbox-hyperskill/gradle-spring image_name: hyperskill-gradle-spring image_tag: 8.5.0-jdk17 - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_hyperskill_java_image: - name: Build epicbox-hyperskill/java image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-hyperskill/java + - path: epicbox-hyperskill/java image_name: hyperskill-java image_tag: 17-jdk-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_hyperskill_node_image: - name: Build epicbox-hyperskill/node image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-hyperskill/node + - path: epicbox-hyperskill/node image_name: hyperskill-node image_tag: 18.20.4-bullseye-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_hyperskill_node_javascript_image: - name: Build epicbox-hyperskill/node-javascript image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-hyperskill/node-javascript + - path: epicbox-hyperskill/node-javascript image_name: hyperskill-node-javascript image_tag: 18.20.4-bullseye-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_hyperskill_python_image: - name: Build epicbox-hyperskill/python image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-hyperskill/python + - path: epicbox-hyperskill/python image_name: hyperskill-python image_tag: 3.10-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_java_image: - name: Build epicbox/java image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-java + - path: epicbox-java image_name: java image_tag: 23-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_kotlin_image: - name: Build epicbox/kotlin image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-kotlin + - path: epicbox-kotlin image_name: kotlin image_tag: 2.0.0-jdk-23-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_mono_image: - name: Build epicbox/mono image - needs: build_debian_image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-mono - image_name: mono - image_tag: 6.10.0.104 - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_node_image: - name: Build epicbox/node image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-node + - path: epicbox-node image_name: node image_tag: 18.20.4-alpine - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_php_image: - name: Build epicbox/php image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-php + - path: epicbox-php image_name: php image_tag: 7.2.11-cli-alpine3.7 - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_pmd_image: - name: Build epicbox/pmd image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-pmd + - path: epicbox-pmd image_name: pmd image_tag: 6.9.0-8u181-alpine - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_python_310_image: - name: Build epicbox/python 3.10 image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-python/310 + - path: epicbox-python/310 image_name: python image_tag: 3.10.6-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_python_311_image: - name: Build epicbox/python 3.11 image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-python/311 + - path: epicbox-python/311 image_name: python image_tag: 3.11.5-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - build_python_312_image: - name: Build epicbox/python 3.12 image - runs-on: [ self-hosted, small ] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-python/312 + - path: epicbox-python/312 image_name: python image_tag: 3.12.7-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - build_ruby_image: - name: Build epicbox/ruby image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-ruby + - path: epicbox-ruby image_name: ruby image_tag: 2.5.3-alpine - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_scala2_image: - name: Build epicbox/scala2 image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-scala/2 + - path: epicbox-scala/2 image_name: scala image_tag: 2.13.12-8u342-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_scala3_image: - name: Build epicbox/scala3 image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-scala/3 + - path: epicbox-scala/3 image_name: scala image_tag: 3.0.0-11.0.11-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_typescript_image: - name: Build epicbox/typescript image - runs-on: [ self-hosted, small ] - timeout-minutes: 15 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build - uses: ./.github/workflows/actions/build - with: - path: epicbox-typescript + - path: epicbox-typescript image_name: typescript image_tag: 4.8.4-18.20.4-bullseye-slim - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - build_hyperstyle_image: - name: Build epicbox/hyperstyle image - runs-on: [ self-hosted, small ] + - path: epicbox-hyperstyle + image_name: hyperstyle + image_tag: ij-2024.9 timeout-minutes: 15 steps: - name: Checkout code @@ -415,42 +136,18 @@ jobs: - name: Build uses: ./.github/workflows/actions/build with: - path: epicbox-hyperstyle - image_name: hyperstyle - image_tag: ij-2024.9 + path: ${{ matrix.path }} + image_name: ${{ matrix.image_name }} + image_tag: ${{ matrix.image_tag }} username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} clean_untagged_images: name: Clean untagged images needs: - - build_clojure_image - build_debian_image - - build_gcc_image - - build_go_image - - build_haskell_image - - build_hyperskill_gcc_image - - build_hyperskill_go_image - - build_hyperskill_gradle_image - - build_hyperskill_gradle_spring_image - - build_hyperskill_java_image - - build_hyperskill_node_image - - build_hyperskill_node_javascript_image - - build_hyperskill_python_image - - build_java_image - - build_kotlin_image - - build_mono_image - - build_node_image - - build_php_image - - build_pmd_image - - build_python_310_image - - build_python_311_image - - build_python_312_image - - build_ruby_image - - build_scala2_image - - build_scala3_image - - build_typescript_image - - build_hyperstyle_image + - build_debian_images + - build_images runs-on: [ self-hosted, small ] timeout-minutes: 30 steps: