From ee88f7176055a3d162a186870e017f45dc7c76ba Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Mon, 9 Dec 2024 15:13:25 +0100 Subject: [PATCH] ci: simplify image build --- .github/workflows/build-image.yml | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/build-image.yml diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 00000000..1e37bb4e --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,53 @@ +name: Build Image + +on: + workflow_dispatch: + workflow_call: + inputs: + tag: + description: 'Tag to build' + required: true + type: string + registry: + description: 'Registry to push to' + required: true + type: string + +concurrency: + group: ${{ github.workflow }} + +jobs: + build: + name: Build Docker image + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker image + run: | + tag=${{ github.event.inputs.tag }} + force_build="" + + if [[ "$tag" == console-api/* ]]; then + app="api" + elif [[ "$tag" == console-web/* ]]; then + app="deploy-web" + force_build="-f" + else + echo "Error: Unknown tag format" + exit 1 + fi + + tag="${tag#*/}" + tag="${tag#v}" + + ./packages/docker/script/build.sh -r ${{ github.event.inputs.registry }} -t $tag -a $app $force_build