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 }}"
|
||||
Reference in New Issue
Block a user