chore(ci): add offline container deployment pipeline
CI / Backend (push) Failing after 8m3s
CI / Deployment Config (push) Successful in 6s
CI / Frontend (push) Successful in 4m4s

This commit is contained in:
2026-04-30 23:29:15 +08:00
parent f3679e6176
commit 22163edbee
13 changed files with 472 additions and 58 deletions
+111
View File
@@ -0,0 +1,111 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
backend:
name: Backend
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: server/go.mod
cache-dependency-path: server/go.sum
- name: Add Go bin to PATH
run: echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- name: Install sqlc
run: go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.30.0
- name: Generate sqlc code
working-directory: server
run: make sqlc-generate
- name: Verify generated code is committed
run: git diff --exit-code -- server/internal/tenant/repository/generated
- name: Check tenant SQL scope guard
working-directory: server
run: make tenant-scope-guard
- name: Run tests
working-directory: server
run: make test
- name: Build Go commands
working-directory: server
run: go build ./cmd/...
frontend:
name: Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup pnpm
run: |
corepack enable
corepack prepare pnpm@10.33.0 --activate
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Typecheck admin web
run: pnpm typecheck:admin
- name: Typecheck ops web
run: pnpm --filter ops-web typecheck
- name: Typecheck browser extension
run: pnpm typecheck:extension
- name: Build admin web
run: pnpm build:admin
- name: Build ops web
run: pnpm --filter ops-web build
deploy-config:
name: Deployment Config
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Docker CLI
run: |
if command -v docker >/dev/null 2>&1; then
docker --version
exit 0
fi
apt-get update
apt-get install -y docker.io docker-compose-plugin
- name: Validate compose files
run: |
docker compose -f deploy/docker-compose.yaml config >/tmp/compose.yaml
docker compose -f deploy/docker-compose.yaml -f deploy/docker-compose.offline.yaml config >/tmp/compose-offline.yaml
- name: Validate shell scripts
run: bash -n deploy/scripts/package.sh deploy/scripts/load-and-start.sh
+93
View File
@@ -0,0 +1,93 @@
name: Offline Package
on:
workflow_dispatch:
inputs:
image_tag:
description: "Docker image tag. Defaults to the current tag name or short commit SHA."
required: false
default: ""
platform:
description: "Target platform for the offline package."
required: false
default: "linux/amd64"
push:
tags:
- "v*"
permissions:
contents: read
jobs:
package:
name: Build Offline Package
runs-on: ubuntu-latest
timeout-minutes: 180
env:
DOCKER_BUILDKIT: "1"
REQUESTED_IMAGE_TAG: ${{ inputs.image_tag }}
REQUESTED_PLATFORM: ${{ inputs.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Docker CLI and buildx
run: |
if command -v docker >/dev/null 2>&1 && docker buildx version >/dev/null 2>&1; then
docker version
docker buildx version
exit 0
fi
apt-get update
apt-get install -y ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
. /etc/os-release
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${VERSION_CODENAME} stable" > /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install -y docker-ce-cli docker-buildx-plugin docker-compose-plugin
docker version
docker buildx version
- name: Check Docker daemon
run: docker info
- name: Resolve package metadata
run: |
image_tag="${REQUESTED_IMAGE_TAG}"
if [ -z "${image_tag}" ]; then
case "${GITHUB_REF:-}" in
refs/tags/*)
image_tag="${GITHUB_REF#refs/tags/}"
;;
*)
image_tag="$(git rev-parse --short=12 HEAD)"
;;
esac
fi
platform="${REQUESTED_PLATFORM:-linux/amd64}"
printf '%s\n' "${image_tag}" > .ci-image-tag
printf '%s\n' "${platform}" > .ci-platform
echo "Image tag: ${image_tag}"
echo "Platform: ${platform}"
- name: Build offline deployment package
run: |
image_tag="$(cat .ci-image-tag)"
platform="$(cat .ci-platform)"
mkdir -p artifacts
PACKAGE_OUTPUT_DIR="${PWD}/artifacts" bash deploy/scripts/package.sh "${image_tag}" "${platform}"
ls -lh artifacts
- name: Upload offline package
uses: actions/upload-artifact@v3
with:
name: geo-rankly-offline-package
path: |
artifacts/*.tar.gz
artifacts/*.sha256
if-no-files-found: error
retention-days: 14