Skip to content

Commit bc3422c

Browse files
committed
Refactor deploy-to-vps.yml
1 parent c382f7f commit bc3422c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

.github/workflows/deploy-to-vps.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,29 @@ jobs:
1515

1616
- name: Deploy to VPS
1717
uses: easingthemes/ssh-deploy@main
18+
env:
19+
VPS_ENV_DIRECTORY: ${{ secrets.VPS_ENV_DIRECTORY }}
1820
with:
1921
SSH_PRIVATE_KEY: ${{ secrets.VPS_SSH_PRIVATE_KEY }}
2022
ARGS: "-rlgoDzvc --delete"
2123
REMOTE_HOST: ${{ secrets.VPS_HOST }}
2224
REMOTE_USER: ${{ secrets.VPS_USER }}
2325
TARGET: ${{ secrets.VPS_TARGET }}
2426
SCRIPT_AFTER: |
25-
# Check if a directory for environment and config files is specified and copy its contents to the current directory if yes
26-
if [ -n "${{ secrets.VPS_ENV_DIRECTORY }}" ] && [ -d "${{ secrets.VPS_ENV_DIRECTORY }}" ]; then cp -ar "${{ secrets.VPS_ENV_DIRECTORY }}"/. .; fi
27-
27+
# Get environment and config files
28+
cp -ar ${{ env.VPS_ENV_DIRECTORY }}/. .
29+
2830
# Detect all usable Compose files ([docker-]compose.yml and [docker-]compose.override.yml) and prefix their filename with "-f "
2931
3032
COMPOSE=$( [ -f "docker-compose.yml" ] && echo -n "-f docker-compose.yml " || true; \
3133
[ -f "docker-compose.override.yml" ] && echo -n "-f docker-compose.override.yml " || true; \
3234
[ -f "compose.yml" ] && echo -n "-f compose.yml " || true; \
3335
[ -f "compose.override.yml" ] && echo -n "-f compose.override.yml " || true )
34-
36+
3537
# Stop, remove, and build the Docker Compose stack
36-
docker compose $COMPOSE stop
37-
docker compose $COMPOSE rm
38+
docker compose $COMPOSE down -v --remove-orphans
3839
sleep 60
3940
docker compose $COMPOSE build --no-cache
4041
docker compose $COMPOSE up -d
4142
docker image prune -af
43+
SCRIPT_AFTER_REQUIRED: true

0 commit comments

Comments
 (0)