Skip to content

Commit fde1460

Browse files
committed
github Containers
1 parent 8499e3e commit fde1460

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch: {}
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to GitHub Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract Docker metadata
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ghcr.io/${{ github.repository }}
38+
tags: |
39+
type=ref,event=branch
40+
type=ref,event=tag
41+
type=sha
42+
type=raw,value=latest,enable={{is_default_branch}}
43+
labels: |
44+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
45+
org.opencontainers.image.revision=${{ github.sha }}
46+
org.opencontainers.image.licenses=MIT
47+
48+
- name: Build and push Docker image
49+
uses: docker/build-push-action@v6
50+
with:
51+
context: .
52+
file: ./Dockerfile
53+
push: true
54+
tags: ${{ steps.meta.outputs.tags }}
55+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)