Update deployment link in README.md #1
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: | |
| # 当推送到 main 分支时触发 | |
| push: | |
| branches: | |
| - main | |
| - master | |
| # 当创建标签时触发 | |
| tag: | |
| - 'v*' | |
| # 允许手动触发 | |
| workflow_dispatch: | |
| # 环境变量 | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_NAME: network-panel | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 检出代码 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| name: Install pnpm | |
| with: | |
| version: 10 | |
| run_install: false | |
| # 安装依赖 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| # 构建项目 | |
| - name: Build project | |
| run: pnpm run build | |
| # 部署到 GitHub Pages | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| if: github.ref == 'refs/heads/main' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./dist | |
| # 可选:自定义域名文件 | |
| # cname: your-domain.com | |
| # 设置 Docker Buildx | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # 登录到 Docker Hub | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| # 提取元数据(标签、标签等) | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| # 为分支创建标签 | |
| type=ref,event=branch | |
| # 为标签创建版本标签 | |
| type=ref,event=tag | |
| # 为主分支创建 latest 标签 | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| # # 使用 Git SHA 创建标签 | |
| # type=sha,prefix={{branch}}- | |
| # 构建并推送 Docker 镜像 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| # 输出镜像摘要 | |
| - name: Image digest | |
| run: echo ${{ steps.build.outputs.digest }} |