Update ecs-deploy.yml #14
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 Ecs | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up SSH | |
uses: webfactory/ssh-agent@v0.5.3 | |
with: | |
ssh-private-key: ${{ secrets.ECS_PRIVATE_KEY }} | |
- name: Upload files to ECS | |
run: | | |
HOST=${{ secrets.ECS_HOST }} | |
USER=${{ secrets.ECS_USER }} | |
PORT=22 | |
ssh -o StrictHostKeyChecking=no $USER@$HOST mkdir -p /$USER/caddyProxy | |
scp -o StrictHostKeyChecking=no -P $PORT Caddyfile $USER@$HOST:/$USER/caddyProxy/Caddyfile | |
scp -o StrictHostKeyChecking=no -P $PORT docker-compose.yml $USER@$HOST:/$USER/caddyProxy/docker-compose.yml | |
- name: Deploy to ECS | |
run: | | |
HOST=${{ secrets.ECS_HOST }} | |
USER=${{ secrets.ECS_USER }} | |
PORT=22 | |
ssh -o StrictHostKeyChecking=no $USER@$HOST << 'EOF' | |
docker compose -f /$USER/caddyProxy/docker-compose.yml down | |
docker compose -f /$USER/caddyProxy/docker-compose.yml up -d | |
EOF |