Skip to content

Commit 07660bb

Browse files
committed
Add GitHub Actions workflow to build and push Docker image (GHCR & Docker Hub)
1 parent 72d9803 commit 07660bb

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and publish Docker image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
env:
15+
DOCKERHUB_REPO: fansichen421/lightllm
16+
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/lightllm
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v2
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v2
26+
27+
- name: Login to GHCR (using GITHUB_TOKEN)
28+
if: ${{ secrets.GITHUB_TOKEN != '' }}
29+
uses: docker/login-action@v2
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Login to Docker Hub
36+
if: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
37+
uses: docker/login-action@v2
38+
with:
39+
registry: docker.io
40+
username: ${{ secrets.DOCKERHUB_USERNAME }}
41+
password: ${{ secrets.DOCKERHUB_TOKEN }}
42+
43+
- name: Build and push multi-platform image
44+
uses: docker/build-push-action@v4
45+
with:
46+
push: true
47+
platforms: linux/amd64,linux/arm64
48+
tags: |
49+
${{ env.DOCKERHUB_REPO }}:latest
50+
${{ env.DOCKERHUB_REPO }}:${{ github.sha }}
51+
${{ env.GHCR_REPO }}:latest
52+
${{ env.GHCR_REPO }}:${{ github.sha }}
53+
cache-from: type=registry,ref=${{ env.DOCKERHUB_REPO }}:cache
54+
cache-to: type=inline

0 commit comments

Comments
 (0)