-
Notifications
You must be signed in to change notification settings - Fork 17
57 lines (46 loc) · 1.35 KB
/
node.js.yml
File metadata and controls
57 lines (46 loc) · 1.35 KB
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
name: React CI/CD Workflow
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code
- name: Checkout repository
uses: actions/checkout@v4
# Step 2: Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18 # Use Node.js 18 or the version your project requires
# Step 3: Install dependencies
- name: Install dependencies
run: npm install
# Step 4: Run tests
- name: Run tests
run: npm test
# Step 5: Build the React application
- name: Build React app
run: npm run build
# Step 6: Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
# Step 7: Build Docker image
- name: Build Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/react-app:latest .
# Step 8: Push Docker image to Docker Hub
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/react-app:latest
# Step 9: List Docker images
- name: List Docker images
run: docker images