ci: add Gitea Actions build and deploy pipeline
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
name: Build, Push and Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master, main, hotfix/*]
|
||||||
|
|
||||||
|
env:
|
||||||
|
HARBOR: 192.168.31.213:10081
|
||||||
|
HARBOR_REGISTRY: 192.168.31.213:10081
|
||||||
|
HARBOR_PROJECT: wordcloud
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login Harbor
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.HARBOR_PASS }}" | docker login "$HARBOR" \
|
||||||
|
-u "${{ secrets.HARBOR_USER }}" --password-stdin
|
||||||
|
|
||||||
|
- name: Build Docker images
|
||||||
|
run: |
|
||||||
|
if docker compose version >/dev/null 2>&1; then
|
||||||
|
COMPOSE="docker compose"
|
||||||
|
else
|
||||||
|
COMPOSE="docker-compose"
|
||||||
|
fi
|
||||||
|
$COMPOSE build
|
||||||
|
|
||||||
|
- name: Tag and push images
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
SHA="${{ github.sha }}"
|
||||||
|
for name in wordcloud-backend wordcloud-frontend; do
|
||||||
|
image="$HARBOR/$HARBOR_PROJECT/$name"
|
||||||
|
docker tag "$image:latest" "$image:$SHA"
|
||||||
|
docker push "$image:latest"
|
||||||
|
docker push "$image:$SHA"
|
||||||
|
done
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout deploy config
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Deploy WordCloud
|
||||||
|
run: |
|
||||||
|
chmod +x ./deploy.sh
|
||||||
|
./deploy.sh wordcloud production "${{ github.sha }}"
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
APP_NAME="${1:-wordcloud}"
|
||||||
|
TARGET_ENV="${2:-production}"
|
||||||
|
IMAGE_TAG="${3:-latest}"
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
if docker compose version >/dev/null 2>&1; then
|
||||||
|
COMPOSE="docker compose"
|
||||||
|
else
|
||||||
|
COMPOSE="docker-compose"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export COMPOSE_PROJECT_NAME="${APP_NAME}"
|
||||||
|
export IMAGE_TAG
|
||||||
|
|
||||||
|
echo "[deploy] project=${APP_NAME} env=${TARGET_ENV} image_tag=${IMAGE_TAG}"
|
||||||
|
$COMPOSE pull
|
||||||
|
$COMPOSE up -d --remove-orphans
|
||||||
|
$COMPOSE ps
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
backend:
|
backend:
|
||||||
image: 114.55.99.6:10081/wordcloud/wordcloud-backend:latest
|
image: "${HARBOR_REGISTRY:-114.55.99.6:10081}/wordcloud/wordcloud-backend:${IMAGE_TAG:-latest}"
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: ./backend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@@ -22,7 +22,7 @@ services:
|
|||||||
start_period: 60s
|
start_period: 60s
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: 114.55.99.6:10081/wordcloud/wordcloud-frontend:latest
|
image: "${HARBOR_REGISTRY:-114.55.99.6:10081}/wordcloud/wordcloud-frontend:${IMAGE_TAG:-latest}"
|
||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
|||||||
Reference in New Issue
Block a user