Skip to content

feat: notice cd error when rollback #28

feat: notice cd error when rollback

feat: notice cd error when rollback #28

Workflow file for this run

name: Backend Deploy
on:
workflow_dispatch:
push:
branches:
- main
paths:
- backend/**
- .github/workflows/be-cd.yaml
- server/docker/docker-compose-be.yaml
- server/docker/docker-compose-db.yaml
jobs:
deploy:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
cache: gradle
- name: Build
working-directory: backend
run: |
chmod +x gradlew
./gradlew build -x test
- name: Copy jar
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
source: backend/build/libs/, server/docker
target: ~/${{ github.event.repository.name }}
- name: Setup environment variables
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
cd ~/${{ github.event.repository.name }}/server/docker
echo "JASYPT_PASSWORD=${{ secrets.JASYPT_PASSWORD }}" > .env
echo "MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }}" >> .env
- name: Update db and be
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
cd ~/${{ github.event.repository.name }}/server/docker
docker compose -f docker-compose-be.yaml pull
docker compose -f docker-compose-db.yaml pull
export $(cat .env)
REPO_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')
docker compose -f docker-compose-db.yaml up -d
docker service ls | grep -iw ${REPO_NAME}_be \
&& docker service update --force ${REPO_NAME}_be \
|| docker stack deploy -c docker-compose-be.yaml ${REPO_NAME}
docker image prune -af
if [[ "$status" != "completed" ]]; then
exit 1
fi