Create action workflow for CI/CD deployment #1
Workflow file for this run
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
| # Created with assistance from GPT-5.6 Terra High | ||
| name: CI/CD - Deploy to VM | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| jobs: | ||
| deploy: | ||
| runs-on: [self-hosted] | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install dependencies | ||
| run: | | ||
| mkdir -p "$TEMPDIR" | ||
| npm ci --no-audit --no-fund | ||
| - name: Build app | ||
| run: npm run Build | ||
| - name: Deploy app to apache | ||
| run: | | ||
| set -euo pipefail | ||
| test -d "/var/www/html/project1" | ||
| test -f dist/index.html | ||
| rsync -a --delete --chmod=D755,F644 \ | ||
| dist/ "/var/www/html/project1/" | ||
| - name: Cleanup job files | ||
| if: always() | ||
| run: | | ||
| set -euo pipefail | ||
| # Removes source checkout, node_modules, dist, npm cache, and TMPDIR. | ||
| # Keeps the runner's own _work directory intact. | ||
| if [ -d "$GITHUB_WORKSPACE" ]; then | ||
| find "$GITHUB_WORKSPACE" -mindepth 1 -maxdepth 1 \ | ||
| -exec rm -rf -- {} + | ||
| fi | ||