更智能的解决api配置反代后的ui路径问题,错误时允许用户手动输入路径 (#122) #296
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 to Docker Hub | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 检出代码 | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # 从 danmu_api/configs/globals.js 中读取版本号 | |
| - name: Read version from globals.js | |
| id: version | |
| run: | | |
| VERSION=$(grep "VERSION:" danmu_api/configs/globals.js | sed -E "s/.*VERSION: '(.*)'.*/\1/") | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| # 根据分支设置版本号后缀 | |
| - name: Set version suffix | |
| run: | | |
| if [ "${{ github.ref }}" != "refs/heads/main" ]; then | |
| echo "VERSION_TAG=${{ env.VERSION }}-test" >> $GITHUB_ENV | |
| else | |
| echo "VERSION_TAG=${{ env.VERSION }}" >> $GITHUB_ENV | |
| fi | |
| # 设置 Docker 镜像缓存(可选,加速构建) | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| # 登录 Docker Hub | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| # 构建 Docker 镜像,并指定平台为 amd64 和 arm64,推送到 Docker Hub | |
| # 使用单条命令同时指定两个标签,避免重复构建 | |
| - name: Build and Push Docker image with version and latest tag | |
| run: | | |
| if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| docker buildx build --platform linux/amd64,linux/arm64 \ | |
| -t ${{ secrets.DOCKER_USERNAME }}/danmu-api:${{ env.VERSION_TAG }} \ | |
| -t ${{ secrets.DOCKER_USERNAME }}/danmu-api:latest \ | |
| --push . | |
| else | |
| docker buildx build --platform linux/amd64,linux/arm64 \ | |
| -t ${{ secrets.DOCKER_USERNAME }}/danmu-api:${{ env.VERSION_TAG }} \ | |
| --push . | |
| fi |