diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 4885f21..6f10594 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -68,18 +68,28 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout deploy files + uses: actions/checkout@v4 + + - name: Upload Docker Compose file + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + source: docker-compose.prod.yml + target: ${{ secrets.DEPLOY_PATH || '/opt/bemeal' }} + - name: Deploy via SSH (Blue/Green) uses: appleboy/ssh-action@v1.0.3 env: IMAGE_TAG: ${{ github.sha }} DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} - REGISTRY_USERNAME: ${{ github.actor }} - REGISTRY_PASSWORD: ${{ secrets.TOKEN_GITEA }} with: host: ${{ secrets.SSH_HOST }} username: ${{ secrets.SSH_USER }} key: ${{ secrets.SSH_PRIVATE_KEY }} - envs: REGISTRY,IMAGE_NAME,IMAGE_TAG,DEPLOY_PATH,REGISTRY_USERNAME,REGISTRY_PASSWORD + envs: REGISTRY,IMAGE_NAME,IMAGE_TAG,DEPLOY_PATH script: | set -eu @@ -95,10 +105,18 @@ jobs: SUDO="sudo" fi + if [ ! -d "$APP_DIR" ]; then + echo "Missing deploy directory: $APP_DIR" + echo "Set the DEPLOY_PATH secret to the directory containing $COMPOSE_FILE." + exit 1 + fi + cd "$APP_DIR" - if [ -n "${REGISTRY_PASSWORD:-}" ]; then - echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" -u "$REGISTRY_USERNAME" --password-stdin + if [ ! -f "$COMPOSE_FILE" ]; then + echo "Missing $APP_DIR/$COMPOSE_FILE" + echo "Set the DEPLOY_PATH secret to the directory containing $COMPOSE_FILE, or copy the compose file there." + exit 1 fi if [ -f "$COMPOSE_ENV_FILE" ]; then