Files
TaskPool/.gitea/workflows/build.yml
T
admin ce9d1b4f1c
Build and Deploy / Build and Push Docker Image (push) Successful in 1m59s
chore(ci): remove debug steps after token verification successful
2026-08-08 02:45:04 +08:00

89 lines
2.5 KiB
YAML

name: Build and Deploy
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
env:
REGISTRY: git.viaeon.com
IMAGE_NAME: admin/taskpool
jobs:
docker:
name: Build and Push Docker Image
runs-on: ubuntu
if: github.event_name == 'push'
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Install Docker CLI
run: |
if ! command -v docker &> /dev/null; then
if command -v apk &> /dev/null; then
apk add --no-cache docker-cli
elif command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y docker.io
else
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz | tar xz -C /tmp
mv /tmp/docker/docker /usr/local/bin/
chmod +x /usr/local/bin/docker
fi
fi
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
run: |
cd /tmp
rm -rf repo
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
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
echo "$TOKEN" | docker login ${{ env.REGISTRY }} -u admin --password-stdin
- name: Build Docker image
run: |
cd /tmp/repo
docker build -f Dockerfile.standalone -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} .
- name: Push Docker image
run: |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}