Add docker publish workflow
Browse files
.github/workflows/docker-publish.yml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Build and Push Docker Image
|
2 |
+
|
3 |
+
on:
|
4 |
+
release:
|
5 |
+
types: [published]
|
6 |
+
|
7 |
+
permissions:
|
8 |
+
contents: read
|
9 |
+
packages: write
|
10 |
+
|
11 |
+
jobs:
|
12 |
+
build-and-push:
|
13 |
+
runs-on: ubuntu-latest
|
14 |
+
steps:
|
15 |
+
- name: Checkout code
|
16 |
+
uses: actions/checkout@v4
|
17 |
+
|
18 |
+
- name: Set up Docker Buildx
|
19 |
+
uses: docker/setup-buildx-action@v3
|
20 |
+
|
21 |
+
- name: Login to GitHub Container Registry
|
22 |
+
uses: docker/login-action@v3
|
23 |
+
with:
|
24 |
+
registry: ghcr.io
|
25 |
+
username: ${{ github.actor }}
|
26 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
27 |
+
|
28 |
+
- name: Extract metadata for Docker
|
29 |
+
id: meta
|
30 |
+
uses: docker/metadata-action@v5
|
31 |
+
with:
|
32 |
+
images: ghcr.io/${{ github.repository }}
|
33 |
+
tags: |
|
34 |
+
type=semver,pattern={{version}}
|
35 |
+
type=semver,pattern={{major}}.{{minor}}
|
36 |
+
type=raw,value=latest,enable={{is_default_branch}}
|
37 |
+
|
38 |
+
- name: Build and push Docker image
|
39 |
+
uses: docker/build-push-action@v5
|
40 |
+
with:
|
41 |
+
context: .
|
42 |
+
push: true
|
43 |
+
tags: ${{ steps.meta.outputs.tags }}
|
44 |
+
labels: ${{ steps.meta.outputs.labels }}
|
45 |
+
cache-from: type=gha
|
46 |
+
cache-to: type=gha,mode=max
|