Skip to content

Commit 79d8192

Browse files
committed
feature : add docker-publish.yaml
instead of building the docker image everytime used, save the docker image to the DockerHub
1 parent b67af94 commit 79d8192

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Docker Publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build-push:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Prepare
16+
id: prep
17+
run: |
18+
DOCKERHUB_IMAGE=kangwonlee/gemini-python-tutor
19+
GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/gemini-python-tutor
20+
VERSION=${GITHUB_REF#refs/tags/v}
21+
MINOR=${VERSION%.*}
22+
MAJOR=${VERSION%%.*}
23+
TAGS="${DOCKERHUB_IMAGE}:${MAJOR},${DOCKERHUB_IMAGE}:${MINOR}"
24+
TAGS="${TAGS},${DOCKERHUB_IMAGE}:${VERSION},${DOCKERHUB_IMAGE}:latest"
25+
TAGS="${TAGS},${GHCR_IMAGE}:${MAJOR},${GHCR_IMAGE}:${MINOR}"
26+
TAGS="${TAGS},${GHCR_IMAGE}:${VERSION},${GHCR_IMAGE}:latest"
27+
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
28+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
29+
echo "dockerhub_image=${DOCKERHUB_IMAGE}" >> $GITHUB_OUTPUT
30+
echo "ghcr_image=${GHCR_IMAGE}" >> $GITHUB_OUTPUT
31+
32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v3
34+
with:
35+
platforms: all
36+
37+
- name: Set up Docker Buildx
38+
id: buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Login to DockerHub
42+
uses: docker/login-action@v3
43+
with:
44+
username: ${{ secrets.DOCKER_USERNAME }}
45+
password: ${{ secrets.DOCKER_PASSWORD }}
46+
47+
- name: Login to Github Container Registry
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.repository_owner }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Build and push
55+
uses: docker/build-push-action@v6
56+
with:
57+
builder: ${{ steps.buildx.outputs.name }}
58+
context: .
59+
file: ./Dockerfile
60+
platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6
61+
push: true
62+
tags: ${{ steps.prep.outputs.tags }}
63+
labels: org.opencontainers.image.version=${{ steps.prep.outputs.version }}

0 commit comments

Comments
 (0)