Docs: Merge quick start guide into README #6
This file contains hidden or 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: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| DOCKER_IMAGE: illyaa/homepage | |
| DOCKER_TAG: latest | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout 代码 | |
| uses: actions/checkout@v4 | |
| - name: 设置 Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: 登录 Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: 提取元数据 | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.DOCKER_IMAGE }} | |
| tags: | | |
| type=raw,value=latest | |
| type=sha,prefix={{branch}}- | |
| - name: 构建并推送 Docker 镜像 | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache | |
| cache-to: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache,mode=max | |
| - name: 触发服务器更新 (可选) | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| echo "镜像已推送到 Docker Hub" | |
| echo "请在服务器上运行: docker compose pull && docker compose up -d" | |