mirror of
https://github.com/sky22333/qqbot.git
synced 2026-06-03 06:41:23 +08:00
add docker
This commit is contained in:
60
.github/workflows/docker-ghcr.yml
vendored
Normal file
60
.github/workflows/docker-ghcr.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
name: ghcr镜像构建
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: '版本号 (例如: v1.0.0)'
|
||||
required: true
|
||||
default: 'v1.0.0'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Log in to GitHub Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set version from input
|
||||
run: |
|
||||
VERSION=${{ github.event.inputs.version }}
|
||||
if [[ $VERSION == v* ]]; then
|
||||
VERSION=${VERSION:1}
|
||||
fi
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Convert repository name to lowercase
|
||||
run: |
|
||||
# 将 github.repository 整体转换为小写
|
||||
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||
echo "REPO_LOWER=$REPO_LOWER" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
docker buildx build --push \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/${{ env.REPO_LOWER }}:${{ env.VERSION }} \
|
||||
--tag ghcr.io/${{ env.REPO_LOWER }}:latest \
|
||||
-f Dockerfile .
|
||||
env:
|
||||
GHCR_PUBLIC: true
|
||||
Reference in New Issue
Block a user