Publish frontend Docker image to GHCR

This commit is contained in:
2026-05-10 13:27:35 +08:00
parent 819b5a4027
commit 0c71229dc0

View File

@@ -5,6 +5,7 @@ on:
permissions:
contents: read
packages: write
concurrency:
group: frontend-build-${{ github.ref }}
@@ -12,32 +13,45 @@ concurrency:
env:
ASTRO_TELEMETRY_DISABLED: '1'
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: Build frontend
build-and-push:
name: Build and push Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
bun-version: 1.3.11
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build frontend
run: bun run build
- name: Upload build output
uses: actions/upload-artifact@v7
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
name: frontend-build-${{ github.run_id }}
path: |
dist
.vercel/output
if-no-files-found: error
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=ref,event=branch
type=sha,prefix=sha-
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max