fix: isolate task node dependencies #201
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: | |
| paths-ignore: | |
| - "*.md" | |
| branches: | |
| - "master" | |
| - "develop" | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| jobs: | |
| code_gitlab: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: Yikun/hub-mirror-action@master | |
| with: | |
| src: github/whyour | |
| dst: gitlab/whyour | |
| dst_key: ${{ secrets.GITLAB_SSH_PK }} | |
| dst_token: ${{ secrets.GITLAB_TOKEN }} | |
| static_list: "qinglong" | |
| force_update: true | |
| code_gitee: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup SSH and push to Gitee | |
| env: | |
| GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} | |
| run: | | |
| set +e | |
| mkdir -p ~/.ssh | |
| printf '%s\n' "${{ secrets.GITLAB_SSH_PK }}" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| ssh-keyscan -T 10 gitee.com >> ~/.ssh/known_hosts 2>/dev/null | |
| git remote add gitee git@gitee.com:whyour/qinglong.git 2>/dev/null | |
| if git push --force --all gitee 2>&1; then | |
| echo "::notice::Gitee push --all succeeded" | |
| else | |
| echo "::warning::Push --all failed, trying to create repo via API..." | |
| curl -sS --connect-timeout 30 --max-time 60 \ | |
| -X POST "https://gitee.com/api/v5/user/repos" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"name":"qinglong","private":"false"}' \ | |
| "?access_token=$GITEE_TOKEN" 2>/dev/null | |
| if git push --force --all gitee 2>&1; then | |
| echo "::notice::Gitee push --all succeeded after repo creation" | |
| else | |
| echo "::warning::Gitee push --all failed after retry" | |
| fi | |
| fi | |
| if git push --force --tags gitee 2>&1; then | |
| echo "::notice::Gitee push --tags succeeded" | |
| else | |
| echo "::warning::Gitee push --tags failed" | |
| fi | |
| build-static: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v6 | |
| with: | |
| version: "8.3.1" | |
| - uses: actions/setup-node@v6 | |
| with: | |
| cache: "pnpm" | |
| cache-dependency-path: pnpm-lock.yaml | |
| - name: build front and back | |
| run: | | |
| pnpm install --frozen-lockfile | |
| pnpm build:front | |
| pnpm build:back | |
| - name: copy to static repo | |
| env: | |
| GITHUB_REPO: github.com/${{ github.repository_owner }}/qinglong-static | |
| GITHUB_BRANCH: ${{ github.ref_name }} | |
| REPO_GITEE: git@gitee.com:whyour/qinglong-static.git | |
| REPO_GITLAB: git@gitlab.com:whyour/qinglong-static.git | |
| PRIVATE_KEY: ${{ secrets.GITLAB_SSH_PK }} | |
| run: | | |
| mkdir -p tmp | |
| cd ./tmp | |
| cp -rf ../static/* ./ | |
| git init -b ${GITHUB_BRANCH} && git add . | |
| git config --local user.name 'github-actions[bot]' | |
| git config --local user.email 'github-actions[bot]@users.noreply.github.com' | |
| git commit --allow-empty -m "copy static at $(date +'%Y-%m-%d %H:%M:%S')" | |
| git push --force --quiet "https://${{ secrets.API_TOKEN }}@${GITHUB_REPO}.git" ${GITHUB_BRANCH}:${GITHUB_BRANCH} | |
| static_gitlab: | |
| needs: build-static | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: Yikun/hub-mirror-action@master | |
| with: | |
| src: github/whyour | |
| dst: gitlab/whyour | |
| dst_key: ${{ secrets.GITLAB_SSH_PK }} | |
| dst_token: ${{ secrets.GITLAB_TOKEN }} | |
| static_list: "qinglong-static" | |
| force_update: true | |
| static_gitee: | |
| needs: build-static | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup SSH | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.GITLAB_SSH_PK }}" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| ssh-keyscan github.com gitee.com >> ~/.ssh/known_hosts | |
| - name: Mirror qinglong-static to Gitee | |
| run: | | |
| git clone --mirror https://github.com/whyour/qinglong-static.git static-mirror | |
| cd static-mirror | |
| git remote set-url origin git@gitee.com:whyour/qinglong-static.git | |
| git push --force --mirror | |
| build: | |
| if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| needs: build-static | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| packages: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v6 | |
| with: | |
| version: "8.3.1" | |
| - uses: actions/setup-node@v6 | |
| with: | |
| cache: "pnpm" | |
| cache-dependency-path: pnpm-lock.yaml | |
| - name: Read version from version.yaml | |
| id: version | |
| run: | | |
| VERSION=$(grep '^version:' version.yaml | awk '{print $2}') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Setup timezone | |
| run: | | |
| sudo timedatectl set-timezone Asia/Shanghai | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: | | |
| ${{ github.repository }} | |
| ghcr.io/${{ github.repository }} | |
| flavor: | | |
| latest=false | |
| tags: | | |
| type=ref,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }} | |
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} | |
| type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.ref == format('refs/heads/{0}', 'master') }} | |
| type=semver,pattern={{version}} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and push | |
| id: docker_build | |
| uses: docker/build-push-action@v7 | |
| with: | |
| build-args: | | |
| MAINTAINER=${{ github.repository_owner }} | |
| QL_BRANCH=${{ github.ref_name }} | |
| SOURCE_COMMIT=${{ github.sha }} | |
| network: host | |
| # linux/s390x npm 暂不可用 | |
| platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/386 | |
| context: . | |
| file: ./docker/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=registry,ref=whyour/qinglong:cache | |
| cache-to: type=registry,ref=whyour/qinglong:cache,mode=max | |
| - name: Image digest | |
| run: | | |
| echo ${{ steps.docker_build.outputs.digest }} | |
| build310: | |
| if: ${{ github.ref_name == 'master' }} | |
| needs: build-static | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| packages: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v6 | |
| with: | |
| version: "8.3.1" | |
| - uses: actions/setup-node@v6 | |
| with: | |
| cache: "pnpm" | |
| cache-dependency-path: pnpm-lock.yaml | |
| - name: Read version from version.yaml | |
| id: version | |
| run: | | |
| VERSION=$(grep '^version:' version.yaml | awk '{print $2}') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Setup timezone | |
| run: | | |
| sudo timedatectl set-timezone Asia/Shanghai | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and push python3.10 | |
| id: docker_build_310 | |
| uses: docker/build-push-action@v7 | |
| with: | |
| build-args: | | |
| MAINTAINER=${{ github.repository_owner }} | |
| QL_BRANCH=${{ github.ref_name }} | |
| SOURCE_COMMIT=${{ github.sha }} | |
| network: host | |
| # linux/s390x npm 暂不可用 | |
| platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/386 | |
| context: . | |
| file: ./docker/310.Dockerfile | |
| push: true | |
| tags: | | |
| whyour/qinglong:python3.10 | |
| whyour/qinglong:${{ steps.version.outputs.version }}-python3.10 | |
| cache-from: type=registry,ref=whyour/qinglong:cache-python3.10 | |
| cache-to: type=registry,ref=whyour/qinglong:cache-python3.10,mode=max | |
| - name: Image digest | |
| run: | | |
| echo ${{ steps.docker_build_310.outputs.digest }} |