refactor(ci): use manual git clone instead of actions/checkout to avoid node dependency
Build and Deploy / Build and Push Docker Image (push) Failing after 9s

- Install Node.js manually using curl
- Use git clone instead of actions/checkout@v4
- Follow license project CI approach
This commit is contained in:
2026-08-08 00:54:51 +08:00
parent 4d38d5df3c
commit bf7e87b582
+33 -43
View File
@@ -15,50 +15,9 @@ env:
IMAGE_NAME: admin/taskpool IMAGE_NAME: admin/taskpool
jobs: jobs:
build:
name: Build Frontend
runs-on: ubuntu
container:
image: node:22
env:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Get pnpm store directory
shell: bash
working-directory: web
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
id: pnpm-cache
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
working-directory: web
run: pnpm install --frozen-lockfile
- name: Build
working-directory: web
run: pnpm build
docker: docker:
name: Build and Push Docker Image name: Build and Push Docker Image
runs-on: ubuntu runs-on: ubuntu
needs: build
if: github.event_name == 'push' if: github.event_name == 'push'
env: env:
RUNNER_TOOL_CACHE: /toolcache RUNNER_TOOL_CACHE: /toolcache
@@ -79,14 +38,45 @@ jobs:
fi fi
docker --version docker --version
- name: Install Node.js
run: |
export PATH="/toolcache/bin:$PATH"
if ! command -v node &> /dev/null; then
if command -v apk &> /dev/null; then
apk add --no-cache nodejs npm
else
curl -fsSL https://nodejs.org/dist/v22.0.0/node-v22.0.0-linux-x64.tar.xz | tar -xJ -C /tmp
cp -r /tmp/node-v22.0.0-linux-x64/{bin,lib,share} /toolcache/
fi
fi
node --version
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 run: |
cd /tmp
git clone --depth=1 https://admin:${{ secrets.TOKEN }}@git.viaeon.com/admin/TaskPool.git repo
cd repo
- name: Setup pnpm
run: |
export PATH="/toolcache/bin:$PATH"
npm install -g pnpm@9
pnpm --version
- name: Install dependencies and build
run: |
export PATH="/toolcache/bin:$PATH"
cd /tmp/repo/web
pnpm install --frozen-lockfile
pnpm build
- name: Login to Registry - name: Login to Registry
run: echo "${{ secrets.TOKEN }}" | docker login ${{ env.REGISTRY }} -u admin --password-stdin run: |
echo "${{ secrets.TOKEN }}" | docker login ${{ env.REGISTRY }} -u admin --password-stdin
- name: Build Docker image - name: Build Docker image
run: | run: |
cd /tmp/repo
docker build -f Dockerfile.standalone -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} . docker build -f Dockerfile.standalone -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} .
- name: Push Docker image - name: Push Docker image