-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (38 loc) · 2.36 KB
/
test-actions.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
name: CI/CD using github actions & docker
on:
pull_request:
branches: ["develop"]
types: ["closed"]
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, '🖥️ Server') }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "18"
- name: Install dependencies
run: |
cd server
npm install
- name: Build Docker image
run: docker build -t geomgichoi/heatpick:latest ./server
- name: Login to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker image to Docker Hub
run: docker push geomgichoi/heatpick:latest
- name: SSH into Ubuntu server and pull the latest image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker pull geomgichoi/heatpick
docker stop heatpick-container || true
docker rm heatpick-container || true
docker run -e SSH_HOST=${{ secrets.SSH_HOST }} -e SSH_PORT=${{ secrets.SSH_PORT }} -e SSH_USER=${{ secrets.SSH_USER }} -e SSH_PASSWORD=${{ secrets.SSH_PASSWORD }} -e DB_USERNAME=${{ secrets.DB_USERNAME }} -e DB_PASSWORD=${{ secrets.DB_PASSWORD }} -e DB_NAME=${{ secrets.DB_NAME }} -e DB_HOST=${{ secrets.DB_HOST }} -e SECRET_KEY=${{ secrets.SECRET_KEY }} -e SLACK_WEBHOOK_URL=${{ secrets.SLACK_WEBHOOK_URL}} -e NCLOUD_ACCESS_KEY=${{secrets.NCLOUD_ACCESS_KEY}} -e NCLOUD_SECRET_KEY=${{secrets.NCLOUD_SECRET_KEY}} -e INVOKE_URL=${{ secrets.INVOKE_URL }} -e GREEN_EYE_SECRET_KEY=${{ secrets.GREEN_EYE_SECRET_KEY }} -v /images:/usr/src/app/images -d -p 3000:3000 --name heatpick-container geomgichoi/heatpick