Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Build and Push

Build and Push #22

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
if [[ BUILD_CHOICE_VALUE=="[All]" ]]; then
echo "services=api frontend" >> $GITHUB_ENV
else
echo "services=$BUILD_CHOICE_VALUE" >> $GITHUB_ENV
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 ${{ env.services }}
- 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