48 lines
1.8 KiB
YAML
48 lines
1.8 KiB
YAML
name: build-deploy
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Build & push iloom services
|
|
run: |
|
|
set -eo pipefail
|
|
REG=localhost:3000/kaezhou
|
|
TAG=dev-$(echo "${{ github.sha }}" | cut -c1-8)
|
|
workdir=$(mktemp -d)
|
|
git clone "http://kaezhou:${{ secrets.REGISTRY_TOKEN }}@localhost:3000/kaezhou/iloom.git" "$workdir"
|
|
cd "$workdir"; git checkout "${{ github.sha }}"
|
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login localhost:3000 -u kaezhou --password-stdin
|
|
for pair in \
|
|
"iloom-gateway:gateway/Dockerfile" \
|
|
"iloom-auth-service:auth-service/Dockerfile" \
|
|
"iloom-purchaser-service:purchaser-service/Dockerfile" \
|
|
"iloom-textile-service:textile-service/Dockerfile" \
|
|
"iloom-washing-service:washing-service/Dockerfile"; do
|
|
name="${pair%%:*}"; df="${pair##*:}"
|
|
echo "::group::build $name ($df)"
|
|
docker build --build-arg BASE_REGISTRY= -f "$df" \
|
|
-t "$REG/$name:$TAG" -t "$REG/$name:latest" .
|
|
docker push "$REG/$name:$TAG"
|
|
docker push "$REG/$name:latest"
|
|
echo "::endgroup::"
|
|
done
|
|
rm -rf "$workdir"
|
|
echo "done: 5 iloom images pushed at $TAG + latest"
|
|
|
|
- name: Deploy to dev-chiba
|
|
run: |
|
|
set -eo pipefail
|
|
app="$HOME/apps/iloom"
|
|
[ -d "$app" ] || { echo "!! $app 未部署,跳过"; exit 0; }
|
|
cd "$app"
|
|
svcs="gateway auth-service purchaser-service textile-service washing-service"
|
|
docker compose pull $svcs
|
|
docker compose up -d $svcs
|
|
docker compose ps --format "table {{.Name}}\t{{.Status}}"
|
|
echo "deployed: $svcs"
|