自动编译 Docker Image 并推送至 Docker Hub
This commit is contained in:
31
.github/workflows/docker-image.yml
vendored
Normal file
31
.github/workflows/docker-image.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: Docker Build and Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # 推送到main分支时触发
|
||||
tags:
|
||||
- 'v*' # 推送v开头的tag时触发(例如v1.0.0)
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: . # Docker构建上下文路径
|
||||
file: ./Dockerfile # Dockerfile路径
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/maimbot:${{ github.ref_name }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/maimbot:latest
|
||||
push: true
|
||||
Reference in New Issue
Block a user