All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m42s
Phases 1-3 split models by domain ownership, but cross-app imports still exist (e.g. cart imports market.models.CartItem). In Docker each app only has its own code. The CI step now copies sibling app model packages into the build context before docker build. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
78 lines
2.5 KiB
YAML
78 lines
2.5 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main, decoupling]
|
|
|
|
env:
|
|
REGISTRY: registry.rose-ash.com:5000
|
|
IMAGE: market
|
|
REPO_DIR: /root/rose-ash/market
|
|
COOP_DIR: /root/coop
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install tools
|
|
run: |
|
|
apt-get update && apt-get install -y --no-install-recommends openssh-client
|
|
|
|
- name: Set up SSH
|
|
env:
|
|
SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "$SSH_KEY" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts 2>/dev/null || true
|
|
|
|
- name: Pull latest code on server
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
run: |
|
|
ssh "root@$DEPLOY_HOST" "
|
|
cd ${{ env.REPO_DIR }}
|
|
git fetch origin ${{ github.ref_name }}
|
|
git reset --hard origin/${{ github.ref_name }}
|
|
git submodule update --init --recursive
|
|
# Copy sibling app models for cross-domain imports
|
|
for sibling in blog market cart events; do
|
|
rm -rf \$sibling/__init__.py \$sibling/models
|
|
if [ -d /root/rose-ash/\$sibling/models ]; then
|
|
mkdir -p \$sibling
|
|
cp /root/rose-ash/\$sibling/__init__.py \$sibling/ 2>/dev/null || touch \$sibling/__init__.py
|
|
cp -r /root/rose-ash/\$sibling/models \$sibling/models
|
|
fi
|
|
done
|
|
"
|
|
|
|
- name: Build and push image
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
run: |
|
|
ssh "root@$DEPLOY_HOST" "
|
|
cd ${{ env.REPO_DIR }}
|
|
docker build --build-arg CACHEBUST=\$(date +%s) \
|
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest \
|
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }} .
|
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
|
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }}
|
|
"
|
|
|
|
- name: Deploy stack
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
run: |
|
|
ssh "root@$DEPLOY_HOST" "
|
|
cd ${{ env.COOP_DIR }}
|
|
source .env
|
|
docker stack deploy -c docker-compose.yml coop
|
|
echo 'Waiting for services to update...'
|
|
sleep 10
|
|
docker stack services coop
|
|
"
|