Release Docker #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Docker | |
on: | |
workflow_dispatch: | |
inputs: | |
target: | |
description: 输入打包版本号 | |
required: true | |
jobs: | |
docker_build: | |
environment: docker_hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build Docker image | |
run: docker build -t dingdangdog/cashbook:${{ github.event.inputs.target }} -t dingdangdog/cashbook:latest . | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push Docker image | |
run: | | |
docker push dingdangdog/cashbook:${{ github.event.inputs.target }} | |
docker push dingdangdog/cashbook:latest | |
# 设置 Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# 构建 arm64 镜像并推送 | |
- name: Build and push arm64 image | |
run: | | |
docker buildx build \ | |
--platform linux/arm64 \ | |
--tag dingdangdog/cashbook:${{ github.event.inputs.target }}-arm64 \ | |
--tag dingdangdog/cashbook:latest-arm64 \ | |
--push . | |
- name: Clean up Docker images | |
run: docker system prune -af |