Skip to content

Commit 0c87715

Browse files
committed
ci: add GitHub Actions workflow for Docker build
- Build on push to main - Push to ghcr.io/happyvertical/tts-server - Tags: latest, sha
1 parent 4cb2c8a commit 0c87715

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- '*.md'
8+
- 'LICENSE'
9+
pull_request:
10+
branches: [main]
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Log in to Container Registry
31+
if: github.event_name != 'pull_request'
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract metadata
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=raw,value=latest,enable={{is_default_branch}}
45+
type=sha,prefix=
46+
type=ref,event=pr
47+
48+
- name: Build and push
49+
uses: docker/build-push-action@v6
50+
with:
51+
context: .
52+
push: ${{ github.event_name != 'pull_request' }}
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
cache-from: type=gha
56+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)