Skip to content

Script to deploy

Script to deploy #16

# .github/workflows/angular-cd.yml
name: Angular CI/CD with Digital Ocean
on:
push:
branches:
- main # Change this to the branch you want to trigger the workflow
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14.x' # Change this to match your project's Node.js version
- name: Install dependencies
run: npm install
- name: Build Angular app
run: npm run build
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to Digital Ocean
uses: appleboy/[email protected]
with:
host: ${{ secrets.DROPLET_IP }}
username: ${{ secrets.DROPLET_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo 'Creating app directory to house the app'
mkdir app
echo 'Cd into the current folder'
cd app
echo 'Clone repo from github to app directory'
git clone [email protected]:factory24/aqm-site.git
echo 'Building the project'
cd aqm-site && npm run build
echo 'Showing current directory items'
ll
echo 'Copy the build files to web server'
cp -f ./dist /var/www/html
echo 'Restart the nginx server'
sudo service nginx restart