added DockerFile for backend and modified tomohub github workflow for… #14
Workflow file for this run
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: Tomohub | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
# Checkout the repository code | |
- name: Checkout Code | |
uses: actions/checkout@v4.2.2 | |
# Generate the image names dynamically | |
- name: Generate Image Names | |
run: | | |
echo FRONTEND_IMAGE=ghcr.io/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]' | tr '[_]' '[\-]')-frontend >> $GITHUB_ENV | |
echo BACKEND_IMAGE=ghcr.io/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]' | tr '[_]' '[\-]')-backend >> $GITHUB_ENV | |
# Log in to GitHub Container Registry | |
- name: Log in to GitHub Docker Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3.3.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Set up Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.7.1 | |
# Build and push the frontend image | |
- name: Build and Push Frontend Image | |
uses: docker/build-push-action@v6.10.0 | |
with: | |
context: ./frontend # Path to the frontend directory | |
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} | |
tags: ${{ env.FRONTEND_IMAGE }}:latest | |
labels: | | |
org.opencontainers.image.source=${{ github.repository_url }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Build and push the backend image | |
- name: Build and Push Backend Image | |
uses: docker/build-push-action@v6.10.0 | |
with: | |
context: ./backend # Path to the backend directory | |
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} | |
tags: ${{ env.BACKEND_IMAGE }}:latest | |
labels: | | |
org.opencontainers.image.source=${{ github.repository_url }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |