Skip to content

Commit 2da2039

Browse files
Add Docker workflow for publishing Docker image
1 parent 611971d commit 2da2039

File tree

3 files changed

+1316
-1
lines changed

3 files changed

+1316
-1
lines changed

.github/workflows/docker.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Publish Docker image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
release:
9+
types: [published]
10+
11+
env:
12+
IMAGE_NAME: ${{ github.event.repository.name }}
13+
14+
jobs:
15+
push-to-docker-hub:
16+
name: Push Docker image to Docker Hub
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check out the repo
20+
uses: actions/checkout@v4
21+
22+
- name: Log in to Docker Hub
23+
uses: docker/login-action@v3
24+
if: github.event_name != 'pull_request'
25+
with:
26+
username: ${{ secrets.DOCKER_USERNAME }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
34+
tags: |
35+
type=ref,event=branch
36+
type=ref,event=pr
37+
type=semver,pattern={{version}}
38+
type=semver,pattern={{major}}.{{minor}}
39+
40+
- name: Build and push Docker image
41+
uses: docker/build-push-action@v5
42+
with:
43+
context: .
44+
push: ${{ github.event_name != 'pull_request' }}
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
47+
48+
- name: Update Docker Hub description
49+
uses: peter-evans/dockerhub-description@v4
50+
if: github.event_name != 'pull_request'
51+
with:
52+
username: ${{ secrets.DOCKER_USERNAME }}
53+
password: ${{ secrets.DOCKER_PASSWORD }}
54+
repository: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
55+
56+
push-to-github-packages:
57+
name: Push Docker image to GitHub Packages
58+
runs-on: ubuntu-latest
59+
60+
env:
61+
REGISTRY: ghcr.io
62+
63+
permissions:
64+
contents: read
65+
packages: write
66+
67+
steps:
68+
- name: Check out the repo
69+
uses: actions/checkout@v4
70+
71+
- name: Log in to GitHub Packages
72+
uses: docker/login-action@v3
73+
if: github.event_name != 'pull_request'
74+
with:
75+
registry: ${{ env.REGISTRY }}
76+
username: ${{ github.actor }}
77+
password: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Extract metadata (tags, labels) for Docker
80+
id: meta
81+
uses: docker/metadata-action@v5
82+
with:
83+
images: ${{ env.REGISTRY }}/${{ github.actor }}/${{ env.IMAGE_NAME }}
84+
tags: |
85+
type=ref,event=branch
86+
type=ref,event=pr
87+
type=semver,pattern={{version}}
88+
type=semver,pattern={{major}}.{{minor}}
89+
90+
- name: Build and push Docker image
91+
uses: docker/build-push-action@v5
92+
with:
93+
context: .
94+
push: ${{ github.event_name != 'pull_request' }}
95+
tags: ${{ steps.meta.outputs.tags }}
96+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules/
2-
package-lock.json
32
bun.lockb
43
build/
54
.env*

0 commit comments

Comments
 (0)