Deploy to Production #1
This file contains hidden or 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 Production | |
on: | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install Tailscale | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y tailscale | |
- name: Authenticate with Tailscale | |
env: | |
TAILSCALE_AUTH_KEY: ${{ secrets.TAILSCALE_AUTH_KEY }} | |
run: | | |
sudo tailscale up --authkey=$TAILSCALE_AUTH_KEY --advertise-routes | |
echo "Tailscale IPs: $(tailscale ip -4)" | |
- name: Add SSH private key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
shell: bash | |
- name: Deploy via SSH | |
env: | |
SERVER_IP: ${{ secrets.SERVER_TAILSCALE_IP }} | |
run: | | |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa user@$SERVER_IP << 'EOF' | |
cd /var/www/ | |
sudo bash deploy-code/deploy-update.sh branch origin/main | |
EOF |