-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (111 loc) · 3.7 KB
/
Copy pathdocker-build-push.yaml
File metadata and controls
128 lines (111 loc) · 3.7 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: ci
on:
push:
branches:
- main
workflow_dispatch:
jobs:
changes:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
backend: ${{ steps.set-filters.outputs.backend }}
worker: ${{ steps.set-filters.outputs.worker }}
steps:
- uses: actions/checkout@v4
- name: Run paths-filter only on push
if: github.event_name == 'push'
id: path-filter
uses: dorny/paths-filter@v3
with:
filters: |
backend:
- 'backend/**'
- 'shared/**'
worker:
- 'worker/**'
- name: Force all outputs on manual run
if: github.event_name == 'workflow_dispatch'
id: force-filter
run: |
echo "backend=true" >> $GITHUB_OUTPUT
echo "worker=true" >> $GITHUB_OUTPUT
- name: Set outputs depending on trigger
id: set-filters
run: |
echo "backend=${{ steps.path-filter.outputs.backend || 'true' }}" >> $GITHUB_OUTPUT
echo "worker=${{ steps.path-filter.outputs.worker || 'true' }}" >> $GITHUB_OUTPUT
backend:
needs: changes
if: needs.changes.outputs.backend == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Set up QEMU (for ARM builds)
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare metadata
id: meta
run: |
msg=$(echo "${{ github.event.head_commit.message }}" | head -n1)
msg=${msg// /_}
echo "short_msg=$msg" >> $GITHUB_OUTPUT
echo "short_sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
- name: Docker Hub Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build & Push Backend
uses: docker/build-push-action@v5
with:
context: .
file: backend/Dockerfile
platforms: linux/arm64
push: true
tags: sunjay195/chatty-ai-backend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
git_commit_sha=${{ github.sha }}
git_commit_short=${{ steps.meta.outputs.short_sha }}
git_commit_msg=${{ steps.meta.outputs.short_msg }}
worker:
needs: changes
if: needs.changes.outputs.worker == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Set up QEMU (for ARM builds)
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare metadata
id: meta
run: |
msg=$(echo "${{ github.event.head_commit.message }}" | head -n1)
msg=${msg// /_}
echo "short_msg=$msg" >> $GITHUB_OUTPUT
echo "short_sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
- name: Docker Hub Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build & Push worker
uses: docker/build-push-action@v5
with:
context: .
file: worker/Dockerfile
platforms: linux/arm64
push: true
tags: sunjay195/chatty-ai-worker:latest
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
git_commit_sha=${{ github.sha }}
git_commit_short=${{ steps.meta.outputs.short_sha }}
git_commit_msg=${{ steps.meta.outputs.short_msg }}