-
Notifications
You must be signed in to change notification settings - Fork 8
80 lines (67 loc) · 2.55 KB
/
test.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
name: Test server CI/CD
on:
push:
branches: ['main', 'develop']
pull_request:
branches: ['main', 'develop']
types: ['opened', 'reopened', 'synchronize', 'closed']
jobs:
CI:
name: Test CI!! 😃
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout 🏁
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Check current directory
run: |
echo "Current directory:"
pwd
echo "Directory content:"
ls -la
- name: Change to project dic
run: cd /home/runner/work/Peer-Frontend/Peer-Frontend
- name: Install packages
run: npm i /home/runner/work/Peer-Frontend/Peer-Frontend
- name: Prettier
working-directory: /home/runner/work/Peer-Frontend/Peer-Frontend
run: npm run format
- name: Lint
working-directory: /home/runner/work/Peer-Frontend/Peer-Frontend
run: npm run lint
- name: Build Test
working-directory: /home/runner/work/Peer-Frontend/Peer-Frontend
run: npm run build
CD:
name: Test CD 👻
if: github.ref == 'refs/heads/develop' && (github.event.pull_request.merged == true || github.event_name == 'push')
runs-on: ubuntu-latest
needs: CI
steps:
- name: Checkout 🏁
uses: actions/checkout@v2
- name: Build and push Docker image
run: |
touch /home/runner/work/Peer-Frontend/Peer-Frontend/.env.production
echo "${{ secrets.ENV_FILE }}" >> /home/runner/work/Peer-Frontend/Peer-Frontend/.env.production
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_TEST_IMAGE }} .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_TEST_IMAGE }}
- name: Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEV_TEST_HOST }}
port: 22
username: ${{ secrets.DEV_TEST_USERNAME }}
password: ${{ secrets.DEV_TEST_KEY }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_TEST_IMAGE }}
docker rm -f ${{ secrets.DOCKER_DEV_TEST_IMAGE }}
docker run -d -p 3000:3000 ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_TEST_IMAGE }}
docker container prune -f
docker image prune -f