Skip to content

Commit a53f5bf

Browse files
committed
ci: 🏗️ add GitHub workflow for Docker build and deployment
1 parent 11376ad commit a53f5bf

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: Build and Deploy to GitHub Registry
3+
4+
on:
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ophiosdev/ocrpdf
14+
15+
jobs:
16+
build-and-push:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check out the repo
20+
id: checkout
21+
uses: actions/checkout@v5
22+
23+
- name: Get the version
24+
id: get_version
25+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
26+
27+
- name: Validate Semver
28+
id: semver
29+
uses: matt-usurp/validate-semver@v2
30+
with:
31+
version: ${{ steps.get_version.outputs.VERSION }}
32+
33+
- name: Log in to the Container registry
34+
id: login_registry
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ghcr.io
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Extract metadata (tags, labels) for Docker
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=semver,pattern={{version}}
48+
type=semver,pattern={{major}}.{{minor}}
49+
type=semver,pattern={{major}}
50+
type=sha
51+
type=raw,value=latest,enable={{is_default_branch}}
52+
labels: |
53+
org.opencontainers.image.maintainer=Ophios GmbH
54+
55+
- name: Build and push Docker image
56+
id: build_and_push
57+
uses: docker/build-push-action@v6
58+
with:
59+
context: .
60+
push: true
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
build-args: |
64+
OCRMYPDF_IMAGE_VERSION=${{ steps.get_version.outputs.VERSION }}

0 commit comments

Comments
 (0)