-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (88 loc) · 3.2 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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 -la
- name: Replace apiGatewayBaseUrl in environment.prod.ts
run: |
sed -i 's|apiGatewayBaseUrl:.*|apiGatewayBaseUrl: "http://$DROPLET_ID_ADDRESS",|' 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: FE_Fitness_Tracker
# - name: Run Tests
# run: npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI
# working-directory: FE_Fitness_Tracker
- name: Build
run: npm run build:prod
working-directory: FE_Fitness_Tracker
- name: Print Folder Structure
run: |
echo "Printing the folder structure:"
ls -la
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist_folder
path: 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: FE_Fitness_Tracker/dist
- name: Build Docker Image
run: docker build -f 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