Skip to content

Commit c4ae81b

Browse files
authored
Create publish-docker-image.yml
1 parent 4fa076a commit c4ae81b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build and Publish Docker image
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
push_to_registry:
13+
name: Push Docker image to ghcr registry
14+
runs-on: ubuntu-latest
15+
permissions:
16+
packages: write
17+
contents: read
18+
19+
steps:
20+
- name: Check out the repo
21+
uses: actions/checkout@v4
22+
23+
- name: Log in to the Github Container registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Extract metadata (tags, labels) for Docker
31+
id: meta
32+
uses: docker/metadata-action@1294d94f8ee362ab42b6da04c35f4cd03a0e6af7
33+
with:
34+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35+
tags: |
36+
type=ref,event=branch,suffix=_{{sha}}
37+
type=raw,value=latest,enable={{is_default_branch}}
38+
39+
- name: Build and push Docker images
40+
uses: docker/build-push-action@v5
41+
with:
42+
context: .
43+
push: true
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)