Some checks failed
Build and Deploy Nuxt / build (push) Has been cancelled
52 lines
1.2 KiB
YAML
52 lines
1.2 KiB
YAML
name: Build and Deploy Nuxt
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: docker
|
|
|
|
container:
|
|
image: node:20
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: ./aranroig
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install SSH client
|
|
run: |
|
|
apt-get update && apt-get install -y openssh-client
|
|
|
|
- name: Setup SSH inside container
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.DEPLOY_KEY_LOCATION }}" > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
|
|
# Add the container host to known_hosts
|
|
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
|
|
|
|
- name: Install deps
|
|
run: npm i
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Compress build
|
|
run: tar -czf build.tar.gz .output
|
|
|
|
- name: Deploy to server
|
|
run: |
|
|
scp build.tar.gz deploy@${{ secrets.DEPLOY_HOST }}:/tmp/
|
|
ssh deploy@{{ secrets.DEPLOY_HOST }} << 'EOF'
|
|
rm -rf /var/www/app/.output
|
|
tar -xzf /tmp/build.tar.gz -C /var/www/app
|
|
sudo systemctl restart app
|
|
EOF
|