feat: add github workflow #1
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 SSH Instance | ||
on: | ||
push: | ||
branches: [main] | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
- name: Install Vite dependencies | ||
run: npm install | ||
- name: Build React app | ||
run: npm run build | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build | ||
path: dist | ||
- name: Deploy to SSH Instance | ||
uses: ssh-actions/ssh-run@v2 | ||
env: | ||
DEPLOY_HOST: ${{ secrets.SSH_HOST }} # Replace with your SSH hostname | ||
DEPLOY_USER: ${{ secrets.SSH_USER }} # Replace with your SSH username | ||
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} # This secret stores your private key | ||
TARGET_DIR: '/var/www/html' # Replace with your deployment directory | ||
with: | ||
commands: | ||
- cd ${{ env.TARGET_DIR }} | ||
- wget https://actions.githubusercontent.com/workflows/downloads/.../$ARTIFACT_NAME-0.tar.gz # Replace with artifact download URL | ||
- tar -xvf $ARTIFACT_NAME-0.tar.gz |