mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
61 lines
1.9 KiB
YAML
61 lines
1.9 KiB
YAML
name: Docker Image CI
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*.*.*' # 只在以 v 开头的标签推送时触发,例如 v1.0.0
|
|
|
|
jobs:
|
|
release:
|
|
name: Release Docker image
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
contents: write
|
|
id-token: write
|
|
issues: write
|
|
|
|
steps:
|
|
- name: Initialization environment
|
|
env:
|
|
DEBIAN_FRONTEND: noninteractive
|
|
run: |
|
|
docker rmi `docker images -q`
|
|
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /etc/mysql /etc/php
|
|
sudo -E apt-get -y purge azure-cli* docker* ghc* zulu* hhvm* llvm* firefox* google* dotnet* aspnetcore* powershell* openjdk* adoptopenjdk* mysql* php* mongodb* moby* snap* || true
|
|
sudo -E apt-get -qq update
|
|
sudo -E apt-get -qq install libfuse-dev $(curl -fsSL git.io/depends-ubuntu-2204)
|
|
sudo -E apt-get -qq autoremove --purge
|
|
sudo -E apt-get -qq clean
|
|
sudo timedatectl set-timezone "$TZ"
|
|
sudo mkdir -p /workdir
|
|
sudo chown $USER:$GROUPS /workdir
|
|
|
|
- name: Check out the repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to the GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.TOKEN }}
|
|
|
|
- name: Extract version from tag
|
|
id: get_version
|
|
run: |
|
|
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
|
|
|
- name: Build and push Docker image
|
|
id: build_push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ github.repository }}:${{ env.VERSION }}
|
|
ghcr.io/${{ github.repository }}:latest
|
|
platforms: linux/amd64,linux/arm64
|