Fix path and add printing to pipeline #2
Workflow file for this run
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: Frontend CI/CD Pipeline | |
#on: | |
# push: | |
# paths: | |
# - 'frontend/FE_Fitness_Tracker/**' | |
# branches: | |
# - main | |
# pull_request: | |
# paths: | |
# - 'frontend/FE_Fitness_Tracker/**' | |
# branches: | |
# - main | |
on: | |
push: | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
env: | |
DROPLET_ID_ADDRESS: ${{ secrets.DROPLET_ID_ADDRESS }} | |
steps: | |
- name: Checkout project sources | |
uses: actions/checkout@v4 | |
- name: Print Folder Structure | |
run: | | |
echo "Printing the folder structure:" | |
ls -R | |
- name: Replace apiGatewayBaseUrl in environment.prod.ts | |
run: | | |
sed -i 's|apiGatewayBaseUrl:.*|apiGatewayBaseUrl: "http://$DROPLET_ID_ADDRESS",|' frontend/FE_Fitness_Tracker/src/environments/environment.prod.ts | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install Dependencies | |
run: npm install | |
working-directory: frontend/FE_Fitness_Tracker | |
- name: Lint | |
run: npm run lint | |
working-directory: frontend/FE_Fitness_Tracker | |
- name: Run Tests | |
run: npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI | |
working-directory: frontend/FE_Fitness_Tracker | |
- name: Build | |
run: npm run build:prod | |
working-directory: frontend/FE_Fitness_Tracker | |
- name: Print Folder Structure | |
run: | | |
echo "Printing the folder structure:" | |
ls -R | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist_folder | |
path: frontend/FE_Fitness_Tracker/dist/ | |
# Add any deployment steps here, specifying the 'working-directory' if needed | |
# Local Deployment Steps (for documentation purposes) | |
- name: Echo Local Deployment Steps | |
run: | | |
echo "Pull the latest code:" | |
echo "git checkout main" | |
echo "git pull origin main" | |
echo "Build the Angular application:" | |
echo "cd path/to/frontend/FE_Fitness_Tracker" | |
echo "npm install" | |
echo "npm run build -- --prod" | |
echo "Deploy locally by copying build artifacts to your local server directory." | |
echo "Start or restart your local server to serve the new version of the application." | |
build-and-push-docker: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
env: | |
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
DOCKER_IMAGE_TAG: registry.digitalocean.com/do-ase-registry/frontend | |
steps: | |
- name: Checkout project sources | |
uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist_folder | |
path: frontend/FE_Fitness_Tracker/dist | |
- name: Build Docker Image | |
run: docker build -f frontend/FE_Fitness_Tracker/Dockerfile -t $DOCKER_IMAGE_TAG FE_Fitness_Tracker | |
- name: GitHub Action for DigitalOcean - doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: $DIGITALOCEAN_ACCESS_TOKEN | |
- name: Log in to DigitalOcean Container Registry with short-lived credentials | |
run: doctl registry login --expiry-seconds 600 | |
- name: Push image to DigitalOcean Container Registry | |
run: docker push $DOCKER_IMAGE_TAG |