尝试github打包镜像

This commit is contained in:
shuaiplus committed 2025-05-27 23:39:02 +08:00
1 parent ae00641a01
commit cdf2f0da64
2 files changed
+57 -1

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
name: Build and Push Docker Image
on:
push:
branches: [ main, master ]
tags: [ 'v*' ]
pull_request:
branches: [ main, master ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
+2 -1
View File
@@ -7,7 +7,8 @@
"build": "vite build",
"dev": " wrangler dev",
"deploy": " wrangler deploy",
"publish": " wrangler publish"
"publish": " wrangler publish",
"build:docker": "vite build"
},
"repository": {
"type": "git",