Skip to content

feat: contest management #51

feat: contest management

feat: contest management #51

Workflow file for this run

name: Build and Push Frontend
on:
# 在推送到 main 或 dev 分支时触发
push:
branches: ["main", "dev"]
# 在向 main 或 dev 分支发起 Pull Request 时触发
pull_request:
branches: ["main", "dev"]
# 允许手动触发
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # 需要写权限来推送镜像到 ghcr.io
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm" # 为 pnpm 设置缓存
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta for frontend
id: meta_frontend
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: . # Dockerfile 所在的上下文路径
file: ./Dockerfile # Dockerfile 的具体路径
platforms: linux/amd64,linux/arm64,linux/arm64/v8
push: ${{ github.event_name == 'push' }} # 仅在 push 事件时推送到 ghcr.io
tags: ${{ steps.meta_frontend.outputs.tags }}
labels: ${{ steps.meta_frontend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max