From 9f2b38df8dd7d73e3673a15ff4b07b3cc7ec9259 Mon Sep 17 00:00:00 2001 From: rjshrjndrn Date: Tue, 5 Jul 2022 09:42:22 +0200 Subject: [PATCH] chore(actions): option to build all/specific services in GH Signed-off-by: rjshrjndrn --- .github/workflows/workers-ee.yaml | 18 ++++++++++++++++++ .github/workflows/workers.yaml | 31 +++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/.github/workflows/workers-ee.yaml b/.github/workflows/workers-ee.yaml index 1637bb794..e937e6cf8 100644 --- a/.github/workflows/workers-ee.yaml +++ b/.github/workflows/workers-ee.yaml @@ -49,6 +49,24 @@ jobs: # # Getting the images to build # + set -x + case ${{ github.event.inputs.build_service }} in + false) + { + git diff --name-only HEAD HEAD~1 | grep -E "backend/cmd|backend/services" | grep -vE ^ee/ | cut -d '/' -f3 + + git diff --name-only HEAD HEAD~1 | grep -E "backend/pkg|backend/internal" | grep -vE ^ee/ | cut -d '/' -f3 | uniq | while read -r pkg_name ; do + grep -rl "pkg/$pkg_name" backend/services backend/cmd | cut -d '/' -f3 + done + } | uniq > /tmp/images_to_build.txt + ;; + all) + ls backend/cmd > /tmp/images_to_build.txt + ;; + default) + echo ${{github.event.inputs.build_service }} > /tmp/images_to_build.txt + ;; + esac git diff --name-only HEAD HEAD~1 | grep backend/services | cut -d '/' -f3 | uniq > backend/images_to_build.txt [[ $(cat backend/images_to_build.txt) != "" ]] || (echo "Nothing to build here"; exit 0) # diff --git a/.github/workflows/workers.yaml b/.github/workflows/workers.yaml index 00aa71912..246e1995d 100644 --- a/.github/workflows/workers.yaml +++ b/.github/workflows/workers.yaml @@ -2,6 +2,11 @@ on: workflow_dispatch: + inputs: + build_service: + description: 'Name of a single service to build(in small letters). "ALL" to build everything' + required: false + default: 'false' push: branches: - dev @@ -48,14 +53,24 @@ jobs: # # Getting the images to build # - - { - git diff --name-only HEAD HEAD~1 | grep backend/services | grep -vE ^ee/ | cut -d '/' -f3 - - git diff --name-only HEAD HEAD~1 | grep backend/pkg | grep -vE ^ee/ | cut -d '/' -f3 | uniq | while read -r pkg_name ; do - grep -rl "pkg/$pkg_name" backend/services | cut -d '/' -f3 - done - } | uniq > backend/images_to_build.txt + set -x + case ${{ github.event.inputs.build_service }} in + false) + { + git diff --name-only HEAD HEAD~1 | grep -E "backend/cmd|backend/services" | grep -vE ^ee/ | cut -d '/' -f3 + + git diff --name-only HEAD HEAD~1 | grep -E "backend/pkg|backend/internal" | grep -vE ^ee/ | cut -d '/' -f3 | uniq | while read -r pkg_name ; do + grep -rl "pkg/$pkg_name" backend/services backend/cmd | cut -d '/' -f3 + done + } | uniq > /tmp/images_to_build.txt + ;; + all) + ls backend/cmd > /tmp/images_to_build.txt + ;; + default) + echo ${{github.event.inputs.build_service }} > /tmp/images_to_build.txt + ;; + esac [[ $(cat backend/images_to_build.txt) != "" ]] || (echo "Nothing to build here"; exit 0) #