mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-06 05:19:51 +08:00
62 lines
1.7 KiB
YAML
62 lines
1.7 KiB
YAML
name: Manual Docker Build & Publish
|
||
|
||
on:
|
||
workflow_dispatch:
|
||
inputs:
|
||
tag:
|
||
description: 'Docker image tag (default: latest)'
|
||
required: false
|
||
default: 'latest'
|
||
|
||
env:
|
||
REGISTRY: ghcr.io
|
||
IMAGE_NAME: ${{ github.repository }}
|
||
|
||
jobs:
|
||
build-and-push:
|
||
runs-on: ubuntu-latest
|
||
# 只在 GitHub 上运行;Gitea 读取 main 时会回退到本目录,需跳过
|
||
if: github.server_url == 'https://github.com'
|
||
permissions:
|
||
contents: read
|
||
packages: write
|
||
|
||
steps:
|
||
- name: Checkout repository
|
||
uses: actions/checkout@v4
|
||
with:
|
||
fetch-depth: 0 # 需要标签来得出版本号
|
||
|
||
- name: Resolve version from tags
|
||
id: version
|
||
run: echo "version=$(git describe --tags --match 'v[0-9]*' 2>/dev/null || true)" >> "$GITHUB_OUTPUT"
|
||
|
||
|
||
# Set up QEMU for multi-arch builds
|
||
- name: Set up QEMU
|
||
uses: docker/setup-qemu-action@v3
|
||
|
||
- name: Set up Docker Buildx
|
||
uses: docker/setup-buildx-action@v3
|
||
|
||
- name: Log in to the Container registry
|
||
uses: docker/login-action@v3
|
||
with:
|
||
registry: ${{ env.REGISTRY }}
|
||
username: ${{ github.actor }}
|
||
password: ${{ secrets.GITHUB_TOKEN }}
|
||
|
||
- name: Build and push Docker image
|
||
uses: docker/build-push-action@v5
|
||
with:
|
||
context: .
|
||
push: true
|
||
platforms: linux/amd64,linux/arm64
|
||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.tag }}
|
||
build-args: |
|
||
APP_VERSION=${{ steps.version.outputs.version }}
|
||
APP_REVISION=${{ github.sha }}
|
||
TEST_TIMEOUT_MS=120000
|
||
cache-from: type=gha
|
||
cache-to: type=gha,mode=max
|