-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (73 loc) · 2.32 KB
/
Copy pathdocker-build-push.yaml
File metadata and controls
86 lines (73 loc) · 2.32 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Build and Push Docker Images
on:
push:
tags:
- "backend*"
- "frontend*"
env:
REGISTRY: ghcr.io
BACKEND_IMAGE_NAME: ${{ github.repository_owner }}/study-app-api
FRONTEND_IMAGE_NAME: ${{ github.repository_owner }}/study-app-web
jobs:
build-and-push-backend:
name: Build and Push Backend
runs-on: ubuntu-latest
# Only run for backend tags
if: contains(github.ref, 'backend')
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tag name
id: tag
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build and push Backend Docker image
uses: docker/build-push-action@v5
with:
context: ./src/backend
push: true
tags: |
${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}
${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:latest
outputs:
tag: ${{ steps.tag.outputs.TAG }}
app: backend
build-and-push-frontend:
name: Build and Push Frontend
runs-on: ubuntu-latest
# Only run for frontend tags
if: contains(github.ref, 'frontend')
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tag name
id: tag
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build and push frontend Docker image
uses: docker/build-push-action@v5
with:
context: ./src/frontend
push: true
tags: |
${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}
${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:latest
outputs:
tag: ${{ steps.tag.outputs.TAG }}
app: frontend