This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
feat(ci): allow to build only part of the images #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
build-choice: | ||
type: choice | ||
description: "Select which containers to build and push to GitHub Container Registry." | ||
required: true | ||
options: | ||
- [All] | ||
- frontend | ||
- api | ||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Save Choice | ||
run: | | ||
BUILD_CHOICE_VALUE="${{ github.event.inputs.build-choice }}" | ||
if [[ -z "$BUILD_CHOICE_VALUE" ]]; then | ||
BUILD_CHOICE_VALUE="[All]" | ||
fi | ||
echo "ci_choice=$BUILD_CHOICE_VALUE" >> $GITHUB_ENV | ||
echo "Received choice: $BUILD_CHOICE_VALUE" | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Log in to GitHub Container Registry | ||
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin | ||
- name: Build images with Docker Compose | ||
run: docker-compose -f docker-compose.ci.yml build | ||
- name: Tag and Push Frontend Image | ||
run: | | ||
docker tag taral_frontend:latest ghcr.io/${{ github.repository_owner }}/taral_frontend:latest | ||
docker push ghcr.io/${{ github.repository_owner }}/taral_frontend:latest | ||
- name: Tag and Push Backend Image | ||
run: | | ||
docker tag taral_api:latest ghcr.io/${{ github.repository_owner }}/taral_api:latest | ||
docker push ghcr.io/${{ github.repository_owner }}/taral_api:latest | ||
- name: Push Images | ||
run: | | ||
if [ "${{ env.ci_choice }}" == "[All]" ] || [ "${{ env.ci_choice }}" == "frontend" ]; then | ||
echo \"Pushing taral_frontend\" | ||
docker tag taral_frontend:latest ghcr.io/${{ github.repository_owner }}/taral_frontend:latest | ||
docker push ghcr.io/${{ github.repository_owner }}/taral_frontend:latest | ||
fi | ||
if [ "${{ env.ci_choice }}" == "[All]" ] || [ "${{ env.ci_choice }}" == "api" ]; then | ||
echo \"Pushing taral_api\" | ||
docker tag taral_api:latest ghcr.io/${{ github.repository_owner }}/taral_api:latest | ||
docker push ghcr.io/${{ github.repository_owner }}/taral_api:latest | ||
fi |