Spaces:
Configuration error
Configuration error
Commit
·
1ccd26e
1
Parent(s):
a18777c
新增自动构建docker镜像
Browse files
.github/workflows/docker-build.yml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Docker Build and Push
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [ "main" ] # 当推送到main分支时触发
|
| 6 |
+
pull_request:
|
| 7 |
+
branches: [ "main" ] # 当对main分支发起PR时触发
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
build-and-push:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
|
| 13 |
+
steps:
|
| 14 |
+
- name: Checkout code
|
| 15 |
+
uses: actions/checkout@v4
|
| 16 |
+
|
| 17 |
+
- name: Login to Docker Hub
|
| 18 |
+
uses: docker/login-action@v3
|
| 19 |
+
with:
|
| 20 |
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
| 21 |
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
| 22 |
+
|
| 23 |
+
- name: Set up Docker Buildx
|
| 24 |
+
uses: docker/setup-buildx-action@v3
|
| 25 |
+
|
| 26 |
+
- name: Build and push
|
| 27 |
+
uses: docker/build-push-action@v5
|
| 28 |
+
with:
|
| 29 |
+
context: .
|
| 30 |
+
push: true
|
| 31 |
+
tags: |
|
| 32 |
+
${{ secrets.DOCKERHUB_USERNAME }}/you2apidocker:latest
|
| 33 |
+
${{ secrets.DOCKERHUB_USERNAME }}/you2apidocker:${{ github.sha }}
|
| 34 |
+
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/you2apidocker:buildcache
|
| 35 |
+
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/you2apidocker:buildcache,mode=max
|