Skip to content

Commit 9d49803

Browse files
authored
Add Docker Hub GitHub Action (#205)
1 parent 37afc6c commit 9d49803

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

.github/workflows/docker-hub.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: docker-hub
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- Dockerfile
8+
- entrypoint.*
9+
- requirements.txt
10+
pull_request:
11+
branches: [ master ]
12+
paths:
13+
- Dockerfile
14+
- entrypoint.*
15+
- requirements.txt
16+
workflow_dispatch:
17+
18+
env:
19+
REGISTRY: laniksj
20+
IMAGE_NAME: ${{ github.repository }}
21+
22+
jobs:
23+
build-and-push-image:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
packages: write
28+
29+
steps:
30+
- name: Checkout Repository
31+
uses: actions/checkout@v4
32+
33+
- name: Login to Docker Hub
34+
uses: docker/login-action@v3
35+
with:
36+
username: ${{ env.REGISTRY }}
37+
password: ${{ secrets.DOCKERHUB_TOKEN }}
38+
39+
- name: Extract Metadata (tags, labels) for Docker
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=raw,value=latest
46+
type=ref,event=branch
47+
48+
- name: Set up Docker Buildx
49+
id: buildx
50+
uses: docker/setup-buildx-action@v3
51+
with:
52+
install: true
53+
54+
- name: Build and Push Docker Image
55+
uses: docker/build-push-action@v5
56+
with:
57+
builder: ${{ steps.buildx.outputs.name }}
58+
context: .
59+
platforms: 'linux/amd64,linux/arm64'
60+
push: true
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/docker-publish.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
paths:
1212
- config/*
1313
- Dockerfile
14+
workflow_dispatch:
1415

1516
env:
1617
REGISTRY: ghcr.io

0 commit comments

Comments
 (0)