-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (53 loc) · 2.05 KB
/
_tomohub.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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