ci: 更新 Docker 镜像构建和发布工作流

- 新增手动构建并发布 Docker镜像的工作流
- 修改发布 Docker 镜像的名称和标签
- 在现有工作流中添加最新标签发布
This commit is contained in:
JoeanAmier
2025-01-08 22:35:43 +08:00
parent 8f344c8438
commit 8f87bb4e5a
5 changed files with 53 additions and 2 deletions

View File

@@ -0,0 +1,45 @@
name: 手动构建并发布 Docker 镜像
on:
workflow_dispatch:
jobs:
publish-docker:
runs-on: ubuntu-latest
steps:
- name: 拉取源码
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: 获取最新的发布标签
id: get-latest-release
run: |
LATEST_TAG=$(curl -s \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/latest \
| jq -r '.tag_name')
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: 设置 QEMU
uses: docker/setup-qemu-action@v3
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 登录到 DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 构建和推送 Docker 镜像到 Docker Hub
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/xhs-downloader:${{ github.event.release.tag_name }}
${{ secrets.DOCKERHUB_USERNAME }}/xhs-downloader:latest

View File

@@ -33,4 +33,6 @@ jobs:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xhs-downloader:${{ github.event.release.tag_name }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/xhs-downloader:${{ github.event.release.tag_name }}
${{ secrets.DOCKERHUB_USERNAME }}/xhs-downloader:latest