Spaces:
Configuration error
Configuration error
| name: Docker Build and Push | |
| on: | |
| push: | |
| branches: [ "main" ] # 当推送到main分支时触发 | |
| pull_request: | |
| branches: [ "main" ] # 当对main分支发起PR时触发 | |
| 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: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/you2apidocker:latest | |
| ${{ secrets.DOCKERHUB_USERNAME }}/you2apidocker:${{ github.sha }} | |
| cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/you2apidocker:buildcache | |
| cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/you2apidocker:buildcache,mode=max | |