Test GitHub Actions expression reading for env.* context #71
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to VPS | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy to VPS | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Deploy to VPS | |
uses: easingthemes/ssh-deploy@main | |
env: | |
VPS_ENV_DIRECTORY: ${{ secrets.VPS_ENV_DIRECTORY }} | |
with: | |
SSH_PRIVATE_KEY: ${{ secrets.VPS_SSH_PRIVATE_KEY }} | |
ARGS: "-rlgoDzvc --delete" | |
REMOTE_HOST: ${{ secrets.VPS_HOST }} | |
REMOTE_USER: ${{ secrets.VPS_USER }} | |
TARGET: ${{ secrets.VPS_TARGET }} | |
SCRIPT_AFTER: | | |
# Get environment and config files | |
echo "${{ env.VPS_ENV_DIRECTORY }}" > test.txt | |
cp -ar ${{ env.VPS_ENV_DIRECTORY }}/. . | |
# Detect all usable Compose files ([docker-]compose.yml and [docker-]compose.override.yml) and prefix their filename with "-f " | |
COMPOSE=$( [ -f "docker-compose.yml" ] && echo -n "-f docker-compose.yml " || true; \ | |
[ -f "docker-compose.override.yml" ] && echo -n "-f docker-compose.override.yml " || true; \ | |
[ -f "compose.yml" ] && echo -n "-f compose.yml " || true; \ | |
[ -f "compose.override.yml" ] && echo -n "-f compose.override.yml " || true ) | |
# Stop, remove, and build the Docker Compose stack | |
docker compose $COMPOSE down -v --remove-orphans | |
sleep 60 | |
docker compose $COMPOSE build --no-cache | |
docker compose $COMPOSE up -d | |
docker image prune -af | |
SCRIPT_AFTER_REQUIRED: true |