Action Workflow #7
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
# .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/scp-action@v1 | |
with: | |
host: ${{ secrets.DROPLET_IP }} # The IP address of your Digital Ocean Droplet | |
username: ${{ secrets.DROPLET_USERNAME }} # The username for accessing the Droplet | |
key: ${{ secrets.SSH_PRIVATE_KEY }} # Your private SSH key (use secrets to store it securely) | |
source: dist/ # The path to your Angular build artifacts | |
target: /var/www/html/ # The web server directory where the app will be deployed |