Repository navigation
test: seed phone heartbeat #5
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 VPS | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: production | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| env: | |
| VPS_PATH: /var/www/sms | |
| SSH_KEY: /home/runner/.ssh/httpsms_deploy | |
| VPS_HOST: ${{ secrets.VPS_HOST }} | |
| VPS_KNOWN_HOSTS: ${{ secrets.VPS_KNOWN_HOSTS }} | |
| VPS_PORT: ${{ secrets.VPS_PORT }} | |
| VPS_SSH_KEY: ${{ secrets.VPS_SSH_KEY }} | |
| VPS_USER: ${{ secrets.VPS_USER }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Configure SSH | |
| run: | | |
| install -m 700 -d "$HOME/.ssh" | |
| printf '%s\n' "$VPS_SSH_KEY" > "$SSH_KEY" | |
| printf '%s\n' "$VPS_KNOWN_HOSTS" > "$HOME/.ssh/known_hosts" | |
| chmod 600 "$SSH_KEY" "$HOME/.ssh/known_hosts" | |
| - name: Sync application | |
| run: | | |
| ssh_args="ssh -i $SSH_KEY -p $VPS_PORT" | |
| target="$VPS_USER@$VPS_HOST:$VPS_PATH" | |
| rsync -az --delete -e "$ssh_args" \ | |
| --exclude='.env' \ | |
| --exclude='*serviceAccountKey.json' \ | |
| api/ "$target/api/" | |
| rsync -az --delete -e "$ssh_args" \ | |
| --exclude='.env' \ | |
| --exclude='.env.local' \ | |
| web/ "$target/web/" | |
| rsync -az -e "$ssh_args" compose.production.yml "$target/" | |
| rsync -az --delete -e "$ssh_args" deploy/ "$target/deploy/" | |
| - name: Deploy and verify | |
| run: | | |
| ssh -i "$SSH_KEY" -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" \ | |
| "GIT_COMMIT=$GITHUB_SHA sh $VPS_PATH/deploy/deploy-vps.sh" |